0
我編程添加單選按鈕:編程充氣單選layout_width不匹配,佈局文件
RadioButton radioButton = (RadioButton) inflater.inflate(R.layout.radio_button, null);
...
radioGroup.addView(radioButton);
在單選按鈕佈局文件,寬度爲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"
但是它添加到後RadioGroup它的寬度是wrap_content:「width:-2」
Timber.e("width: %s", radioGroupReason.getChildAt(radioGroupReason.getChildCount() -1).getLayoutParams().width);