1 如果是布局文件中声明的RadioButton,可以用如下方法:
设置button属性的值为 @null
<RadioButton
android:layout_width="match_parent"
android:layout_height="40dp"
android:button="@null"
android:text="aaaaaaaa"/>
注意:网上有些说,可以直接设置button的值为空串“”,测试不行,报错,提示”Error:(13, 24) String types not allowed (at ‘button’ with value ”).”,不能将String赋值给Button
2 如果是通过代码生成的RadioButton
如果是代码生成的RadioButton,有两种方式取消圆圈,这两种方式都是设置setButtonDrawable(),只是取值不同,具体如下:
LinearLayoutCompat.LayoutParams params = new LinearLayoutCompat.LayoutParams(ViewGroup.LayoutParams
.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
LinearLayout ll = (LinearLayout) findViewById(R.id.activity_main);
RadioButton button = new RadioButton(this);
button.setText("这是代码创建的RadioButton");
// button.setButtonDrawable(new ColorDrawable(Color.TRANSPARENT)); //取消圆圈
button.setButtonDrawable(0); //取消圆圈方式2
ll.addView(button, params);
}