I don't know how to start the title.
At present, I will focus on two aspects:
1. Code setting @ null
// Null is not allowed here. You must set radioButton as follows. setButtonDrawable (getResources (). getDrawable (android. r. color. transparent); // For background, you can simply use nullradioButton. setBackground (null );
2. Create a control object using a layout Template
First, create an xml Script Template for the layout of a single control that contains all default parameters. This is similar to the item layout script used to create a ListView.
<?xml version="1.0" encoding="utf-8"?><RadioButton xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_weight="1" android:background="@null" android:button="@null" android:drawablePadding="-20dp" android:drawableTop="@drawable/cat" />
Introduce the template above through code to create a new object
RadioButton radioButton = (RadioButton) getLayoutInflater().inflate(R.layout.radiobutton, null);