[英]Change background color of programmatically created radio button
我使用了各種方法,但是找不到改變以編程方式創建的RadioButton
的顏色的方法。 除了使用背景圖片,還有其他方法嗎? minSDKVersion
為21
。 下面是我創建RadioButton
。
RadioButton radio = new RadioButton(co);
要以編程方式更改RadioButton
按鈕的顏色,請使用此功能。 因為您的minSdk is 21
。 您可以通過這種方式使用setButtonTintList
。
RadioButton raPrivate = new RadioButton(co);
int textColor = Color.parseColor(#000000);
raPrivate.setButtonTintList(ColorStateList.valueOf(textColor));
如果要更改單選按鈕的背景顏色,請嘗試以下操作:
radioButton.setBackgroundColor(Color.GREEN);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.