Android:以编程方式更改单选按钮和复选框的颜色 [英] Android: Change the color of RadioButtons and checkboxes programmatically

查看:20
本文介绍了Android:以编程方式更改单选按钮和复选框的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以编程方式在 LinearLayout 中创建了 RadioButtonCheckBox.但是,现在我想更改单选按钮的颜色和复选框的颜色.我用

I created RadioButton and CheckBox in LinearLayout programatically. But, now I want to change radio button's color and check boxes's color. I use

RadioButton.setHighlightColor(Color.parseColor("#0c83bd"));

checkbox.setHighlightColor(Color.parseColor("#0c83bd"));

但是没有用.

推荐答案

试试这个

AppCompatRadioButton newRadioButton = new AppCompatRadioButton(this);
AppCompatCheckBox newCheckBox = new AppCompatCheckBox(this);

插入

RadioGroup newRadioButton = new RadioGroup(this);
CheckBox newCheckBox = new CheckBox(this);

这篇关于Android:以编程方式更改单选按钮和复选框的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆