RadioButton左边设置图片大小,右边设置单选按钮大小的通用方法
2017-12-28 13:40
681 查看
public static void changeSize(int[] radio_buttons, int[] drawables, AppCompatActivity activity,int radio_button) { if(radio_button!=0){
//这里radio_buttons是要设置的单选按钮,drawables是左边图片组,radio_button是单选按钮
for (int i=0;i<radio_buttons.length;i++){ RadioButton radioButton= (RadioButton) activity.findViewById(radio_buttons[i]); Drawable thing_sign = activity.getResources().getDrawable(drawables[i]); thing_sign.setBounds(0, 0, 50, 50); Drawable radio_button_sign=activity.getResources().getDrawable(radio_button); radio_button_sign.setBounds(0,0,50,50); radioButton.setCompoundDrawables(thing_sign, null, radio_button_sign, null); } }else{ for (int i=0;i<radio_buttons.length;i++){ RadioButton radioButton= (RadioButton) activity.findViewById(radio_buttons[i]); Drawable thing_sign = activity.getResources().getDrawable(drawables[i]); thing_sign.setBounds(0, 0, 50< 9163 span style="color:#cc7832;">, 50); radioButton.setCompoundDrawables(null, thing_sign, null, null); } } } }
附上radio_button的代码,供参考
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_checked="true" android:drawable="@drawable/radio_checked"/> <item android:state_checked="false" android:drawable="@drawable/nothing"/> </selector>
相关文章推荐
- qt 设置单选按钮(checkbox或radiobutton等)的方法
- android 单选按钮 RadioButton 自定义图片左边距
- android ViewPager在拖拽到左边和右边的时候,禁止显示黄色或者蓝色的渐变图片的解决方法
- PHP设置图片文件上传大小的具体实现方法
- android ViewPager在拖拽到左边和右边的时候,禁止显示黄色或者蓝色的渐变图片的解决方法
- PHP设置图片文件上传大小的具体实现方法
- 通过代码设置改变radiobutton图片大小
- js使用DOM设置单选按钮、复选框及下拉菜单的方法
- PHP设置图片文件上传大小的具体实现方法
- IOS设置导航栏全局的背景图片、导航栏title文字颜色大小、导航栏左右按钮的颜色。
- Java中如何设置按钮背景图片大小
- Android中如何设置RadioButton在文字的右边,图标在左边
- 基于jquery的文章中所有图片width大小批量设置方法
- Android ImageView设置图片的可见性,设置颜色的不同方法,设置图片指定大小
- ASP.NET单选按钮控件RadioButton常用属性和方法介绍
- zk框架获取POI Excel图片 以及 设置图片位置和大小的方法
- radioButton图片大小的设置
- Ubuntu 14.04中设置关闭按钮放到标题栏右边的方法
- RadioGroup、RadioButton(单选按钮)、CheckBox(多选按钮)和Toast的使用方法