下面是一些代碼you..You可以做這樣的事情。如果你有任何問題,我可以郵寄給你整個項目。希望這可以幫助你和其他人。 !
RES /抽拉/ red_ring.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadiusRatio="3"
android:shape="ring"
android:thickness="10dp"
android:useLevel="false" >
<solid android:color="#FF0000" />
<size
android:height="30dp"
android:width="30dp" />
</shape>
RES /抽拉/ blue_ring.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadiusRatio="3"
android:shape="ring"
android:thickness="5dp"
android:useLevel="false" >
<solid android:color="#0000FF" />
<size
android:height="20dp"
android:width="20dp" />
</shape>
RES /抽拉/ layer.xml中
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/red_ring"/>
<item android:drawable="@drawable/blue_ring"/>
</layer-list>
RES /抽拉/ selector_radio.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_checked="true" android:drawable="@drawable/layer"></item>
<item android:drawable="@drawable/blue_ring"></item>
</selector>
RES /佈局/ activity_main.xml中
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<RadioGroup
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:gravity="center" >
<RadioButton
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:button="@drawable/selector_radio"
android:paddingLeft="30dp"
android:text="Radio 1" />
<RadioButton
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:button="@drawable/selector_radio"
android:paddingLeft="30dp"
android:text="Radio 2" />
</RadioGroup>
</RelativeLayout>
截圖:
非常感謝你幾乎給我確切的樣子(我需要的是像無線電2,但顏色交換)我會嘗試編輯它,並獲得我需要的外觀。 –
酷......如果你覺得這個有用,那麼不要忘記接受並注意。 –
我不會忘記,但我有一個問題:我該如何設置邊框,或者應該怎麼說,以便選定的收音機看起來像int照片(問題中的鏈接),現在我只能弄清楚如何將它設置爲單個顏色 –