I created a custom icon bar in Android using an XML layout creator using the RadioGroup in LinearLayout (see XML below). Each RadioButton in the RadioGroup has a custom (with checked and uncontrolled states) custom option with the android:button attribute.
The linear layout itself is located inside the RelativeLayout so that it can be displayed in an arbitrary position on the screen (in this case, it is a sidebar).
The output objects are 55 pixels wide, and the android:layout\_width all these views is wrap\_content .
When I make this component visible, aligned in the lower left corner of the screen, only about three quarters of the width of the RadioButton image are visible. Setting layout\_width from RelativeLayout to fill\_parent fixes this and causes a full button to appear.
However, this means that the button group uses click events across the entire width of the screen.
How can I make the whole button pressed, and only on the click response button? Hard coding of the width of the extruded is not a particularly desirable solution.
<RelativeLayout android:id="@+id/RelativeLayout01" android:layout_width="wrap_content" android:layout_height="wrap_content"> <LinearLayout android:id="@+id/LinearLayout02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_below="@+id/LinearLayout01" android:visibility="invisible"> <RadioGroup android:id="@+id/RadioGroup01" android:layout_height="wrap_content" android:checkedButton="@+id/RB01" android:layout_width="fill_parent"> <RadioButton android:id="@+id/RB01" android:layout_width="fill_parent" android:layout_height="wrap_content" android:button="@drawable/DR01"/> <RadioButton android:id="@+id/RB02" android:layout_width="fill_parent" android:layout_height="wrap_content" android:button="@drawable/DR02"/> <RadioButton android:id="@+id/RB03" android:layout_width="fill_parent" android:layout_height="wrap_content" android:button="@drawable/DR03"/> <RadioButton android:id="@+id/RB04" android:layout_width="fill_parent" android:layout_height="wrap_content" android:button="@drawable/DR04"/> </RadioGroup> </LinearLayout> </RelativeLayout>
source share