我正在尝试创建不填满整个宽度的选项卡。
我目前正在使用 ActionBar 选项卡,并且也将其设为蓝色 + 选项卡,但不幸的是它会将其拉伸以使其宽度相等。
有什么方法可以使用操作栏选项卡来做到这一点?如果没有,我可以使用 TabHost/TabWidget 吗?我希望页面的内容是一个控制实际页面内容的 ViewPager。
我当前的 XML 文件看起来很简单:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
当我试用 TabHost 时,我尝试了这个:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@android:id/tabhost">
<LinearLayout
android:id="@+id/LinearLayout01"
android:orientation="vertical"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TabWidget
android:id="@android:id/tabs"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
>
</TabWidget>
<Button
android:layout_height="wrap_content"
android:layout_width="46dp"
android:background="#00F"
android:text="+"
>
</Button>
</LinearLayout>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
</FrameLayout>
</LinearLayout>
这给了我类似的东西:
但我不知道我的 ViewPager 适合它。
我也无法弄清楚如何对操作栏选项卡进行以下自定义:
- 小写而不是全部大写
- 标签高度
- 选定的条形颜色
- 所选字体
- 选中/未选中的文本颜色
- 字体大小
任何想法,将不胜感激。谢谢!