如何设置顶部和底部的布局Android
问题描述:
我试图在上面创建这个布局,但我无法得到它。 所有这些块都是图像。前两行是我使用适配器填充OnCreate的GridView。没关系,它显示在屏幕上方。 我的问题是应该在屏幕底部对齐的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>
非常感谢。
答
与该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>
答
你需要让你的根布局相对布局和什么哟想设置在底部增加都在同一个layhout并在下面给出资产的设计布局。而已。
android:layout_alignParentBottom="true"
工作就像一个魅力! – 2015-04-02 14:03:51