Facebookのナビゲーションバーを実装するために、次のレイアウト構成があります。
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<!-- This is the Lower Layer hosting the navbar -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<!-- ListView representing the navbar -->
<ListView
/>
</LinearLayout>
<!-- This is the Top Layer hosting the Content -->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<!-- This is where the View of the Content will be injected -->
</FrameLayout>
</FrameLayout>
つまり、基本的な考え方は、ナビゲーションバーを開きたいときに、 TopLayerを右にシフトするだけで、ナビゲーションバーが表示されるということです。これでうまく機能し、アプリケーション内を移動するためにナビゲーションバーを操作できます。ただし、内部に挿入されるビューが(別の、、、またはのように) ない場合に限ります。ListView
TopLayer
ScrollableView
ListView
ScrollView
WebView
たとえば、TopLayer
がインスタンスの場合、スクロールされるのはナビゲーションバーであるため、スクロールしてナビゲーションバーWebView
を操作することはできません(右にシフトしましたが)。 ListView
WebView
多くのを重ね合わせるのは簡単ではないと思いますScrollableView
が、これらの問題を克服するためのハックがあることを願っています。
ご協力いただきありがとうございます!
編集
ちなみに、これは私がTopLayer
ビューをシフトする方法です(TranslateAnimationを使用):
TranslateAnimation translateAnim = new TranslateAnimation(0.0F, mListView.getWidth(), 0.0F, 0.0F);
translateAnim.setDuration(..);
translateAnim.setFillAfter(true);
mTopLayerView.startAnimation(translateAnim);