这是我的 TabLayout xml 代码:
<android.support.design.widget.TabLayout
app:tabBackground="@drawable/profile_tab_selector"
android:id="@+id/profileTabLayout"
android:layout_width="match_parent"
android:layout_height="28dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
app:tabGravity="fill"
app:tabIndicatorHeight="0dp"
app:tabMode="fixed"
app:tabSelectedTextColor="@color/colorPrimary"
app:tabTextColor="@color/white">
</android.support.design.widget.TabLayout>
这是tabBackground="@drawable/profile_tab_selector":
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true">
<shape>
<stroke android:width="1dp" android:color="@color/white"/>
<solid android:color="@color/white"/>
</shape>
</item>
<item>
<shape>
<stroke android:width="1dp" android:color="@color/white"/>
<solid android:color="@color/blue"/>
</shape>
</item>
</selector>
我想像这样设计它,带有圆角:
问题是在选择器中我无法检测到第一个和最后一个选项卡来修改它们。这是结果:
12345678_0001
相关分类