圆角选中的tablayout

来源:互联网 发布:php九九乘法表表格 编辑:程序博客网 时间:2024/06/14 08:15

这里写图片描述

<android.support.design.widget.TabLayout            android:id="@+id/table_layout"            android:layout_width="150dp"            android:layout_height="30dp"            android:layout_gravity="center"            android:background="@drawable/tablayout_background"            android:textColor="@android:color/black"            android:textSize="13sp"            app:tabBackground="@drawable/tab_background"            app:tabIndicatorHeight="0dp"            app:tabSelectedTextColor="@color/white"            app:tabTextColor="@color/main_color" />

app:tabBackground为标签背景
android:background为tablayout背景
tab_background(标签背景)

//设置选中背景为tablayout_select_background<selector xmlns:android="http://schemas.android.com/apk/res/android">    <item android:drawable="@drawable/tablayout_select_background" android:state_selected="true" /></selector>

tablayout_select_background(选中标签背景)

//选中的背景<shape xmlns:android="http://schemas.android.com/apk/res/android">    <corners android:radius="40dp" />    <solid android:color="@color/main_color" /></shape>

android:background(tablayout背景)

<shape xmlns:android="http://schemas.android.com/apk/res/android">    <corners android:radius="40dp" />    <stroke        android:width="1dp"        android:color="@color/main_color" /></shape>
0 0