以编程方式将无线电按钮的边距或填充添加到无线电组中
我想以编程方式向 RadioGroup 添加边距或填充,但它不起作用。
无线电按钮:
<RadioButton xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_fruit"
android:button="@null"
android:checked="false" />
无线电组:
<RadioGroup
android:id="@+id/radio_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:orientation="horizontal">
</RadioGroup>
Java 代码:
RadioButton radioButtonView = (RadioButton) getActivity().getLayoutInflater().inflate(R.layout.radio_button, null);
radioGroup.addView(radioButtonView);
我试图使用,但它不起作用LayoutParams
dividerPadding