Android傻ui问题

时间:2011-03-12 16:53:51

标签: android user-interface android-layout

我是Android上的新手,我的应用程序设计存在一个愚蠢的问题。

我的问题是我想制作一个网格,如本例http://developer.android.com/guide/tutorials/views/hello-gridview.html所示 但我想在网格下面创建一个texbox,在网格后面创建一个按钮。文本框必须始终位于顶部,按钮始终位于底部。我这样做了:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical">
<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/textView1" 
    android:layout_marginLeft="20px" 
    android:text="@string/intro" 
    android:layout_marginTop="20px" 
    android:textSize="35px">
</TextView>
<GridView 
    android:id="@+id/gridView1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent">
    android:numColumns="auto_fit"
    android:verticalSpacing="10dp"
    android:horizontalSpacing="10dp"
    android:columnWidth="90dp"
    android:stretchMode="columnWidth"
    android:gravity="center"
</GridView>
<Button 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/Button_create" 
    android:textSize="18px">
    android:id="@+id/button1">
</Button>
</LinearLayout>

但是使用这段代码我的文本框位于顶部,而不是底部的按钮。它在网格完成时出现。另外我注意到在示例中,网格内部有2 o 3列,但是使用此代码只显示一个,我不知道为什么。

你能帮帮我吗?

PS。对于谁将编辑代码区,你能解释一下当一行结束时我必须把它放到但是它继续代码吗?谢谢,抱歉你的时间编辑我的帖子

1 个答案:

答案 0 :(得分:0)

您应该设置android:layout_gravity的值,例如1到你已确定填充父级高度的GridView,然后对于Button,将值设为0.5。