2012-02-18 98 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