2014-02-02 4 views
0

Я хочу создать пользовательский интерфейс, похожий на следующее изображение. Я понятия не имею, чтобы выровнять кнопки на экране. Мне интересно, должен ли я создавать фрагменты.Использование фрагментов в дизайне андроида

android screen sample

+0

Существует несколько способов добиться того, что вам нужно. Вам не нужно создавать фрагменты. RelativeLayout с несколькими ImageButtons будет достаточно. – MadDeveloper

+1

Решение об использовании фрагментов ортогонально к дизайну макета для сетки 3х2. – selbie

+0

Проверьте мой ответ, но вы можете использовать относительный макет, но при редактировании элементов он немного сумасшедший. – Elshan

ответ

1

Попробуйте это!

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:orientation="horizontal" > 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_weight="0.47" > 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="vertical" > 

       <Button 
        android:id="@+id/button1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="Button" /> 

       <Button 
        android:id="@+id/button6" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="Button" /> 

       <Button 
        android:id="@+id/button7" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="Button" /> 

       <Button 
        android:id="@+id/button8" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="Button" /> 

      </LinearLayout> 

     </LinearLayout> 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_weight="0.47" > 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="vertical" > 

       <Button 
        android:id="@+id/button2" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="Button" /> 

       <Button 
        android:id="@+id/button3" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="Button" /> 

       <Button 
        android:id="@+id/button4" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="Button" /> 

       <Button 
        android:id="@+id/button5" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="Button" /> 

      </LinearLayout> 

     </LinearLayout> 

    </LinearLayout> 

</RelativeLayout> 

Вы можете отрегулировать запас и дополнение в соответствии с вашими требованиями.

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