2011-03-12 115 views
0

我是Android新手,我的應用程序設計有一個愚蠢的問題。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個3列,但是這個代碼只出現一個,我不知道爲什麼。

你能幫我嗎?

PS。對於誰將編輯代碼區域,您能否向我解釋當線路結束時必須放置的內容,但它會繼續執行代碼?感謝和抱歉你的時間編輯我的帖子

+0

我不完全確定你的意思是「什麼時候行結束並繼續代碼。」對於降價編輯器有一些有用的信息,編輯器上面有一個橙色的問號,鏈接到:http://stackoverflow.com/editing-help希望有所幫助。 – 2011-03-12 17:00:29

+0

我的意思是在第一行結束後,我應該如何繼續所有代碼設計,直到最後一行代碼?因爲我按了添加代碼,並且我粘貼了所有代碼,並且代碼的設計只是在第一行,就像你看到的那樣。 – Eureka 2011-03-12 17:03:30

+0

呵呵,好吧,格式化它的一個好方法是將所有代碼放在編輯器中,然後選擇代碼並按下編輯器上的'{}'按鈕以有效地將代碼縮進爲代碼,這也會請注意在需要的地方添加額外的行,將其與以前的文本分開。我強烈建議通過減價幫助,並讓自己熟悉。 – 2011-03-12 17:05:54

回答

0

你應該把一個android:layout_gravity值例如。 1至GridView,您已決定填充父級的高度,然後爲Button指定0.5的值。