<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/imageview"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_margin="3dp"
/>
<TextView
android:id="@+id/textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="1dp"
android:textSize="12sp"
android:layout_marginBottom="2dp"/>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="false" android:drawable="@drawable/ic_launcher" />
<item android:state_selected="true" android:drawable="@drawable/ic_launcher_round" />
</selector>
注:模板有5个tab,需要5个图片选择器,还需要5个文本选择器,还需要创建5个fragment。如果要动态改变文本点击变色,需要用getResources().getColorStateList(R.color.main_bottom_text_selector)才可以,getColor()只会选取一种颜色。