2015-04-02 5 views
0

Я пытаюсь создать этот макет выше, но я не могу его получить. Все эти блоки, являются изображениями. Первые две строки - GridView, которые я заполняю OnCreate с помощью адаптера. Все в порядке, оно отображается в верхней части экрана. Моя проблема заключается в том, чтобы 5 изображений были выровнены в нижней части экрана. Я не знаю, что я делаю неправильно.Как настроить макет сверху и снизу Android

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:background="@drawable/img_fundo_pp"> 
    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
    <GridView android:id="@+id/grid1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:padding="10dip" 
     android:verticalSpacing="10dip" 
     android:horizontalSpacing="10dip" 
     android:numColumns="auto_fit" 
     android:columnWidth="90dip" 
     android:gravity="center" 
     android:layout_gravity="top" /> 
</RelativeLayout> 
    <View android:id="@+id/spacer" 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"/> 
     <GridLayout 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:columnCount="3" 
      android:rowCount="3" 
      android:useDefaultMargins="true" 
      android:layout_gravity="top"> 
      <Space android:layout_width="10dp" /> 
      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/imageView" 
       android:src="@drawable/btn_link_site"/> 
      <Space android:layout_width="10dp" /> 
      <Space android:layout_width="10dp" /> 
      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/imageView2" 
       android:clickable="true" 
       android:src="@drawable/btn_link_facebook"/> 
      <Space android:layout_width="10dp" /> 
      <Space android:layout_width="10dp" /> 
      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/imageView3" 
       android:src="@drawable/btn_link_htmj_pp" 
       android:clickable="true"/> 
      <Space android:layout_width="10dp" /> 
      </GridLayout> 
</LinearLayout> 

desired layout

Спасибо большое.

ответ

0

Дизайн макета с этим XML

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

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_weight="1" > 

    <GridView 
     android:id="@+id/grid1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:columnWidth="90dip" 
     android:gravity="center" 
     android:horizontalSpacing="10dip" 
     android:numColumns="auto_fit" 
     android:padding="10dip" 
     android:verticalSpacing="10dip" /> 
</LinearLayout> 

<View 
    android:id="@+id/spacer" 
    android:layout_width="match_parent" 
    android:layout_height="40dp" /> 

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

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_weight="1" 
     android:orientation="horizontal" > 

     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_margin="10dp" 
      android:layout_weight="1" /> 

     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_margin="10dp" 
      android:layout_weight="1" /> 
    </LinearLayout> 

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

     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_margin="10dp" 
      android:layout_weight="1" /> 

     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_margin="10dp" 
      android:layout_weight="1" /> 

     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_margin="10dp" 
      android:layout_weight="1" /> 
    </LinearLayout> 
</LinearLayout> 

+0

Работал как очарование! –

0

Вы должны сделать свой корень макет Относительного расположение и любой года хотят установить в нижней части добавить все в одном layhout и Приводит собственность. Вот и все.

android:layout_alignParentBottom="true" 
Смежные вопросы