我将RadioButton的android:drawable属性通过编程方式设置为以下内容:
我通过以下方式设置RadioButton的android:drawable属性:
Drawable unchecked = getResources().getDrawable(R.drawable.ic_room_car);
Drawable d= getResources().getDrawable(R.drawable.ic_room_car);
Shape circle = ?????;
??? checked = combine circle and d
SateListDrawable states= new StateListDrawable();
states.addState(new int[] {android.R.attr.state_checked}, checked);
states.addState(new int[] {}, unchecked);
((RadioButton)findViewById(R.id.icon_1)).setButtonDrawable(states);
基本上,它具有自定义图标,在未选中时我从资源中读取该图标,而在选中时,我想在图标后面绘制一个圆形。
未选中的行为在第二个addState行中设置,并且它正在工作。我的问题是如何编程绘制一个圆并将其与我从资源中读取的可绘制对象结合起来。