按鈕的圖片變換

第一步:選擇好想要的原始圖片android

xinwen

和變化圖片佈局

xinwen1

在drawable裏設置xml

selector佈局 《zixun》圖片

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@mipmap/xinwen" android:state_checked="false"/>
    <item android:drawable="@mipmap/xinwen1" android:state_checked="true"/>
</selector>

第二步:按鈕調用《zixun》ip

<RadioGroup
    android:gravity="center"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <RadioButton
        android:id="@+id/zhonghe"
        android:button="@null"
        android:text="綜合"
        android:checked="true"
        android:gravity="center"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_margin="5dp"
        android:layout_height="wrap_content"
        android:drawableTop="@drawable/zixun"
         />
</RadioGroup>
相關文章
相關標籤/搜索