android - Radio Button in one radio group in 2 horizontal line -
i try set 4 radio button in 1 radio group in 2 lines, problem when take linear layout horizontal orientation radio group functionality not work . radio buttons select . @ time 1 button should select.
<linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" > <radiobutton android:id="@+id/r1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/lbl1" /> <radiobutton android:id="@+id/r2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/lbl2" /> </linearlayout> <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" > <radiobutton android:id="@+id/r3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/lbl3" /> <radiobutton android:id="@+id/r4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/lbl4" /> </linearlayout> </radiogroup>
i dont know if still need option can "force" second line using this:
- set orientation of radiogroup horizontal
- second set same margintop in radiobuttons in same "line"
- third set negative marginstart on first element of every (2 , forward) mark star of each line , other elements follow
here example of this:
<radiogroup android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:id="@+id/rgroup"> <radiobutton android:id="@+id/r1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/lbl1" /> <radiobutton android:id="@+id/r2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/lbl2" /> <radiobutton android:id="@+id/r3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginstart="-180dp" android:layout_margintop="40dp" android:text="@string/lbl3" /> <radiobutton android:id="@+id/r4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginstart="0dp" android:layout_margintop="40dp" android:text="@string/lbl4" /> </radiogroup>
Comments
Post a Comment