我正在设置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 行中设置,并且它正在工作。我的问题是如何以编程方式绘制一个圆圈,然后以某种方式将其与我从资源中读取的可绘制对象结合起来。
这是一个图层列表。
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@mipmap/ic_launcher" android:left="10dp" android:right="10dp" android:top="10dp" android:bottom="10dp">
</item>
<item>
<shape android:shape="oval">
<solid android:color="@android:color/transparent"></solid>
<stroke android:color="#4b14b1" android:width="1dp"></stroke>
<size android:height="50dp" android:width="50dp"></size>
</shape>
</item>
</layer-list>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)