我有一个tabbedactivity布局,但是我需要自定义布局以在2个活动之间滑动,就像这样。
我不能更改背景颜色,只能更改线条指示器。有人知道我该怎么做吗?
<android.support.design.widget.AppBarLayout
android:id="@+id/appbarBottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.TabLayout
android:id="@+id/tabsBottom"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>
thx!
答案 0 :(得分:0)
要更改所选项目的背景色,您必须使用 app:tabBackground 并设置自定义选择器。
tab_selector:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/colorPrimaryDark" android:state_selected="true"/>
<item android:drawable="@color/colorPrimary"/>
</selector>
TabLayout:
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabBackground="@drawable/tab_selector">...