2013-07-29 2 views
1

У меня есть 4 переключателя. Под этими кнопками я хочу текст. Радиокнопки должны находиться в центре над текстом. Я попытался объединить их в линейную компоновку (текст и кнопку), но затем я потерял функцию радиогруппы, потому что радиокнопки должны быть прямыми дочерними элементами радиогруппы. Как я могу это сделать?Центр радиотелефона Android над текстом

<RadioGroup 
     android:id="@+id/radio_group" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <RadioButton 
      android:id="@+id/radioButton0" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:gravity="center" /> 

     <RadioButton 
      android:id="@+id/radioButton1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:gravity="center" /> 

     <RadioButton 
      android:id="@+id/radioButton2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:gravity="center" /> 

     <RadioButton 
      android:id="@+id/radioButton3" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:gravity="center" /> 
    </RadioGroup> 

    <LinearLayout 
     android:id="@+id/container_timeline" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <TextView 
      android:id="@+id/seek_timeline_morning" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:gravity="center" 
      android:text="@string/timeline_morning" /> 

     <TextView 
      android:id="@+id/seek_timeline_noon" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:gravity="center" 
      android:text="@string/timeline_noon" /> 

     <TextView 
      android:id="@+id/seek_timeline_evening" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:gravity="center" 
      android:text="@string/timeline_evening" /> 

     <TextView 
      android:id="@+id/seek_timeline_night" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:gravity="center" 
      android:text="@string/timeline_night" /> 
    </LinearLayout> 

! [Введите описание изображения здесь] [1]

+0

использовать относительное расположение, так что вы можете поместить все элементы соответственно – Giant

+0

использования 'андроид: гравитация = center_horizontal' –

+0

@SatineKainne Должен ли я использовать Относительный Layout вместо шахты Линейного или новый относительно вокруг моих и радио-группы линейного макета? – NcmX

ответ

0

Поместите относительное расположение в линейной компоновки и разместить кнопки радио внутри!

Я всегда использую относительную компоновку, она намного адаптивна, когда вы привыкаете к элементам управления.

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