簡體   English   中英

如何在Android中更改單選按鈕的顏色?

[英]How to Change Color of Radio Button in android?

我想知道如何在android中更改單選按鈕的圓形和邊框的顏色。請幫我嘗試兩天。

更簡單,只需設置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"/>

在您的values / colors.xml中,在這種情況下將您的顏色變成紅色:

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

您需要將drawable設置為RadioButton才能更改顏色和邊框或邊框的任何其他部分。

您可以在此處找到更多信息: RadioButton-如何使用自定義可繪制對象?

您可以使用tint功能,但是在較舊的設備中無法使用。 如果您不支持<API 21。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM