I'm adding RadioButtons programmatically:
RadioButton radioButton = (RadioButton) inflater.inflate(R.layout.radio_button, null);
...
radioGroup.addView(radioButton);
In the RadioButton layout file, the width is match_parent:
android:layout_width="match_parent"
android:layout_height="match_parent"
android:button="@null"
android:drawableLeft="@drawable/check_selector"
android:drawablePadding="@dimen/large"
android:paddingBottom="@dimen/large"
android:paddingTop="@dimen/large"
android:textColor="@drawable/text_selector"
however after adding it to the RadioGroup it's width is wrap_content: "width: -2"
Timber.e("width: %s", radioGroupReason.getChildAt(radioGroupReason.getChildCount() -1).getLayoutParams().width);
before adding view use it:
radioButton.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With