2012-02-18 94 views
1
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/linearLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

    <LinearLayout 
     android:id="@+id/linearLayout2" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1.85" 
     android:orientation="horizontal" android:layout_marginTop="10px"> 

     <EditText 
      android:id="@+id/editText1" 
      android:layout_width="299dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" android:lines="1"/> 

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

    </LinearLayout> 

    <ListView 
     android:id="@+id/mylist" 
     android:layout_height="413dp" 
     android:layout_weight="0.52" android:layout_width="fill_parent"> 

</ListView> 

</LinearLayout> 

上消失,有什麼不對的佈局?文本編輯鍵盤

1)當我在縱向模式下打開這個應用程序是文字編輯,直到看到我點擊以輸入一些文字(只有黑色)。如果我不是把它變成橫向模式的文本編輯再次出現(在全屏模式下)

2)當我打開在橫向模式下的應用程序只存在佈局標題和下面再黑暗。

它似乎並沒有太複雜.. 這裏是僞XML:

<row> 
    <col. for text> 
    <col. for button> 
</row> 
<row> 
    <some text here> 
</row> 

你能幫我解決這個佈局,或給我一些更好的例子嗎?

回答

1

您有413dp的高度(非常巨大)列表視圖。我想你誤會layout_weight決定如何分配過剩空間,其中還有的不會非常多給你的列表視圖是如此之大。

你可能想要的是設置你的水平的LinearLayout有沒有layout_weight告訴列表視圖來使用它:

<ListView 
    android:id="@+id/mylist" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:layout_width="fill_parent" 
    > 
</ListView> 
+0

就是這樣。玩圖形佈局會很煩人...... – gisek 2012-02-18 18:35:53