drawable 的屬性在平常基礎的使用中用到的大都是
<shape></shape>
<selector></selector>
現(xiàn)在給兩個demo說明一下這兩個屬性的基本使用
當然不僅僅只有這兩個屬性的使用,shape里面還有其它很多屬性的使用奋蔚,比如可以實現(xiàn)背景顏色她混、改變形狀、漸變色等等泊碑。這里就不多說坤按。
接下倆是seletor的使用,使用步驟相似馒过,這里給你們貼一個demo自己看下吧~
<?xml version="1.0" encoding="utf-8"?>
? ? android:layout_width="match_parent"
? ? android:layout_height="wrap_content">
? ? ? ? ? ? android:layout_alignParentBottom="true"
? ? ? ? ? ? android:orientation="horizontal"
? ? ? ? ? ? android:layout_width="match_parent"
? ? ? ? ? ? android:layout_height="wrap_content">
? ? ? ? ? ? ? ? android:layout_width="0dp"
? ? ? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? ? ? android:layout_weight="1"
? ? ? ? ? ? ? ? android:text="AAA"
? ? ? ? ? ? ? ? android:button="@null"
? ? ? ? ? ? ? ? android:drawableTop="@drawable/gadiogroup"
? ? ? ? ? ? ? ? android:gravity="center_horizontal"
? ? ? ? ? ? ? ? android:textColor="@drawable/textcolor"/>
? ? ? ? ? ? ? ? android:layout_width="0dp"
? ? ? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? ? ? android:layout_weight="1"
? ? ? ? ? ? ? ? android:text="AAA"
? ? ? ? ? ? ? ? android:button="@null"
? ? ? ? ? ? ? ? android:drawableTop="@drawable/gadiogroup"
? ? ? ? ? ? ? ? android:gravity="center_horizontal"
? ? ? ? ? ? ? ? android:textColor="@drawable/textcolor"/>
? ? ? ? ? ? ? ? android:layout_width="0dp"
? ? ? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? ? ? android:layout_weight="1"
? ? ? ? ? ? ? ? android:text="AAA"
? ? ? ? ? ? ? ? android:button="@null"
? ? ? ? ? ? ? ? android:drawableTop="@drawable/gadiogroup"
? ? ? ? ? ? ? ? android:gravity="center_horizontal"
? ? ? ? ? ? ? ? android:textColor="@drawable/textcolor"/>
? ? ? ? ? ? ? ? android:layout_width="0dp"
? ? ? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? ? ? android:layout_weight="1"
? ? ? ? ? ? ? ? android:text="AAA"
? ? ? ? ? ? ? ? android:button="@null"
? ? ? ? ? ? ? ? android:drawableTop="@drawable/gadiogroup"
? ? ? ? ? ? ? ? android:gravity="center_horizontal"
? ? ? ? ? ? ? ? android:textColor="@drawable/textcolor"/>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
? ? <item android:state_checked="true" android:drawable="@drawable/add_"></item>
? ? <item android:drawable="@drawable/add"></item>
</selector>
做完之后臭脓,添加圖片就能實現(xiàn)類似于微信底部的布局,點擊換圖片腹忽,更換文字顏色的功能来累。
ps:第一次寫,不好請見諒
2018年11月6日