我希望能有一个自定义导航的 ActionBar,其中自定义视图看起来像标准 ActionBar 标签。我知道这听起来像是重新发明轮子,但这意味着我们可以像下面展示的那样把菜单按钮放在同一行标签上。这是一个设计要求,在这个应用程序中,它比标准的 Android 行为更加实用且更合理地利用了 UI。
我尝试使用 ActionBarSherlock 中的 IcsLinearLayout:
<IcsLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:orientation="horizontal"
android:layout_height="50dip">
<Button
android:id="@+id/tab_1"
android:layout_height="match_parent"
android:gravity="center"
android:layout_width="wrap_content"
android:textStyle="bold"
android:text="TAB_1"
android:background="@drawable/abs__item_background_holo_light"
/>
<Button
android:id="@+id/tab_2"
android:layout_height="match_parent"
android:gravity="center"
android:layout_width="wrap_content"
android:textStyle="bold"
android:text="TAB_2"
android:background="@drawable/abs__item_background_holo_light"
/>
</IcsLinearLayout>
但这只复制了ActionButtons,我不知道如何复制Tabs。
我认为我需要:
- 一个特殊的选项卡容器ViewGroup(可能来自ActionBarSherlock库)
- 看起来像选项卡的视图,具有ABS库中的背景资源。
- 一些代码表明在视图被点击后它仍然被选中(类似于RadioButton)。
任何关于示例或类似解决方案的提示(即使在ActionBarSherlock库中),都将非常感激。