2014-02-17 3 views
0

У меня есть поиск много раз, чтобы выровнять каждую кнопку радио в радио группы по горизонталикнопки Align RadioGroup horzintally

, но не повез, примечание: у меня есть много радио группы каждых радио группы в днище другого и так далее.

и некоторых радио группа имеет три кнопки радио или только две радиостанции

как я могу исправить это выровнять?

примечание: я хочу, чтобы выровнять радиокнопку сам он не радио текст

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@drawable/bg" 
tools:context=".DartboardActivity" > 

<RelativeLayout 
    android:id="@+id/game_layout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/buttons" 
    android:layout_alignParentTop="true" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" > 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentTop="true" 
     android:layout_marginTop="30dp" 
     android:text="فحص قياس الزيت" 
     android:textColor="@color/FontColorLogin" 
     android:textSize="30sp" /> 

    <RadioGroup 
     android:id="@+id/radioGroup1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginRight="90dp" 

     android:layout_alignParentTop="true" 
     android:layout_marginTop="30dp" 
     android:orientation="horizontal" > 

     <RadioButton 
      android:id="@+id/radio1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:button="@null" 
      android:drawableRight="@drawable/checkbox_background" 
      android:text="غير كامل" 
      android:layout_weight="1" 
      android:textColor="@color/FontColorLogin" 
      android:textSize="20sp" /> 

     <RadioButton 
      android:id="@+id/radio0" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:button="@null" 
      android:checked="true" 
      android:layout_weight="1" 
      android:drawableRight="@drawable/checkbox_background" 
      android:text="كامل" 
      android:textColor="@color/FontColorLogin" 
      android:textSize="20sp" /> 

    </RadioGroup> 

    <TextView 
     android:id="@+id/textView2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_below="@+id/textView1" 
     android:layout_marginTop="60dp" 
     android:text="فحص جودة الزيت" 
     android:textColor="@color/FontColorLogin" 
     android:textSize="30sp" /> 

    <RadioGroup 
     android:id="@+id/radioGroup2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_marginRight="90dp" 
     android:layout_below="@+id/radioGroup1" 
     android:layout_marginTop="60dp" 
     android:orientation="horizontal" > 

     <RadioButton 
      android:id="@+id/radio3" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/radio1" 
      android:layout_weight="1" 
      android:button="@null" 
      android:drawableRight="@drawable/checkbox_background" 
      android:text="محترق" 
      android:textColor="@color/FontColorLogin" 
      android:textSize="20sp" /> 

     <RadioButton 
      android:id="@+id/radio2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:layout_weight="1" 
      android:button="@null" 
      android:checked="true" 
      android:drawableRight="@drawable/checkbox_background" 
      android:text="غير كامل" 
      android:textColor="@color/FontColorLogin" 
      android:textSize="20sp" /> 

     <RadioButton 
      android:id="@+id/radio1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:button="@null" 
      android:checked="true" 
      android:drawableRight="@drawable/checkbox_background" 
      android:text="كامل" 
      android:layout_weight="1" 
      android:textColor="@color/FontColorLogin" 
      android:textSize="20sp" /> 
    </RadioGroup> 
</RelativeLayout> 

<LinearLayout 
    android:id="@+id/buttons" 
    android:layout_width="match_parent" 
    android:layout_height="60dp" 
    android:layout_alignParentBottom="true" 
    android:background="#333" 
    android:orientation="horizontal" > 

    <Button 
     android:id="@+id/button1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="150dp" 
     android:background="@drawable/gallery" /> 

    <Button 
     android:id="@+id/button2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="@drawable/camera" /> 

    <Button 
     android:id="@+id/Button3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="@drawable/syncoff" /> 

    <Button 
     android:id="@+id/button4" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="@drawable/save" /> 
</LinearLayout> 

+0

Вы пробовали GridView? – Angelika

+0

Что вы подразумеваете под выравниванием? вы хотите, чтобы все они были в одной горизонтальной линии? – nikis

+0

Да, я хочу сделать первый столбец для первого радио для каждой группы, а второй столбец для второго радио и так один – user3245658

ответ

0

Начало использования layout_weight собственности. Это свойство правильно выравнивает элементы управления.

Edit:

Человек есть слишком много ошибок в макете

  1. Ориентация в относительной макете
  2. Кнопка LinearLayout свойства
  3. Layout_weight свойство используется дважды и т.д.

Не ошибаетесь ли вы в своем XML ???

Отредактировано: -

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
tools:context=".DartboardActivity" > 

<RelativeLayout 
    android:id="@+id/game_layout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" > 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentTop="true" 
     android:layout_marginTop="30dp" 
     android:text="hello" 
     android:textSize="30sp" /> 

    <RadioGroup 
     android:id="@+id/radioGroup1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_marginRight="90dp" 
     android:layout_marginTop="30dp" 
     android:orientation="horizontal" > 

     <RadioButton 
      android:id="@+id/radio1" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:button="@null" 
      android:drawableRight="@drawable/ic_launcher" 
      android:text="hello" 
      android:textSize="20sp" /> 

     <RadioButton 
      android:id="@+id/radio0" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:button="@null" 
      android:checked="true" 
      android:drawableRight="@drawable/ic_launcher" 
      android:text="hello" 
      android:textSize="20sp" /> 

     <RadioButton 
      android:id="@+id/radio2" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:visibility="invisible" /> 
    </RadioGroup> 

    <TextView 
     android:id="@+id/textView2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_below="@+id/textView1" 
     android:text="hello" 
     android:textSize="30sp" /> 

    <RadioGroup 
     android:id="@+id/radioGroup2" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/radioGroup1" 
     android:layout_marginRight="90dp" 
     android:orientation="horizontal" > 

     <RadioButton 
      android:id="@+id/radio3" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/radio1" 
      android:layout_weight="1" 
      android:button="@null" 
      android:drawableRight="@drawable/ic_launcher" 
      android:text="hello" 
      android:textSize="20sp" /> 

     <RadioButton 
      android:id="@+id/radio2" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:layout_weight="1" 
      android:button="@null" 
      android:checked="true" 
      android:drawableRight="@drawable/ic_launcher" 
      android:text="hello" 
      android:textSize="20sp" /> 

     <RadioButton 
      android:id="@+id/radio1" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:button="@null" 
      android:checked="true" 
      android:drawableRight="@drawable/ic_launcher" 
      android:text="hello" 
      android:textSize="20sp" /> 
    </RadioGroup> 

    <LinearLayout 
     android:id="@+id/buttons" 
     android:layout_width="match_parent" 
     android:layout_height="60dp" 
     android:layout_alignParentBottom="true" 
     android:background="#333" 
     android:orientation="horizontal" > 

     <Button 
      android:id="@+id/button1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="@drawable/ic_launcher" /> 

     <Button 
      android:id="@+id/button2" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:background="@drawable/ic_launcher" /> 

     <Button 
      android:id="@+id/Button3" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:background="@drawable/ic_launcher" /> 

     <Button 
      android:id="@+id/button4" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:background="@drawable/ic_launcher" /> 
    </LinearLayout> 
</RelativeLayout> 

+0

Я использовал его в каждом переключателе, но без эффекта – user3245658

+0

разместите здесь полный код –

+0

попробуйте использовать 'LinearLayout' –

Смежные вопросы