【发布时间】:2012-04-19 05:49:48
【问题描述】:
为了实现导航栏ala 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>
所以基本的想法是,当我想打开 navbar 时,我只需将 TopLayer 向右移动,导航栏就会显示出来。
现在这很好用,我可以与 navbar 的 ListView 交互,以便在应用程序中导航,只要注入到 TopLayer 中的视图不是 ScrollableView(比如另一个ListView、ScrollView或WebView)。
例如,当TopLayer是WebView实例时,我无法滚动并与导航栏的 ListView进行交互,因为滚动的是WebView(尽管我把它移到了右边)。
我想叠加许多ScrollableView 并不是一件容易的事,但我希望有一些技巧可以克服这些问题。
感谢您的帮助!
编辑
顺便说一句,这就是我转移TopLayerview 的方式(使用TranslateAnimation):
TranslateAnimation translateAnim = new TranslateAnimation(0.0F, mListView.getWidth(), 0.0F, 0.0F);
translateAnim.setDuration(..);
translateAnim.setFillAfter(true);
mTopLayerView.startAnimation(translateAnim);
【问题讨论】:
标签: android android-layout android-side-navigation