android - Radio Button in one radio group in 2 horizontal line -


enter image description here

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:

  1. set orientation of radiogroup horizontal
  2. second set same margintop in radiobuttons in same "line"
  3. 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

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -