2013-04-25 131 views
6

如何更改android中單選按鈕的邊框顏色?如何更改android中單選按鈕的邊框顏色?

我想更改android單選按鈕的圓形顏色。

在此先感謝。任何幫助是極大的讚賞。

我必須嘗試不同的soluation和關注,如果任何財產是否有其他的是可繪製的圖像

+1

http://stackoverflow.com/a/2716089/1838457 – 2013-04-25 11:13:28

回答

17

最簡單的方式來定製(改變顏色)的意見。

轉到:http://android-holo-colors.com/

  • 選擇您想要的單選按鈕的顏色
  • 下載輸出資源(Download.Zip)
  • 解壓縮zip內容
  • 從提取的zip文件複製到您的項目可繪製,樣式和值
  • 將您的應用主題的父級更改爲您下載的主題
  • 而且你得到了你想要的東西
2

我想你正在嘗試定製內置的單選按鈕。試試這個鏈接。這是你的解決方案。全N最後。 Click here

19

沒錯,這就是你正在尋找的屬性:buttonTint,但只適用於API級別21以上

<RadioButton 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/radio" 
    android:checked="true" 
    android:buttonTint="@color/your_color"/> 
在你的價值觀

/colors.xml把你的膚色在這種情況下,一個紅色之一:

<color name="your_color">#e75748</color> 

結果:

Colored Android Radio Button

+6

據我所知,在API級別這僅適用於21或更高。這意味着它不會對較低版本的Android產生影響。 – March3April4 2015-07-31 09:57:03

+0

你說得對,我忘了告訴,謝謝,我已經更新了這篇文章以包含它 – 2015-08-01 18:46:12

3

嘗試使用AppCompatRadioButton

<android.support.v7.widget.AppCompatRadioButton 
    android:id="@+id/rb" 
    app:buttonTint="@color/colorAccent" //This to set your default button color 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"/> 

欲瞭解更多詳情檢查這個答案:Android: Change the color of RadioButtons and checkboxes programmatically