2011-08-13 42 views
0

我试图让屏幕上的4个布局...但它只能说明我的前两个:(
(我是小白)这里是我的代码:的Android,得到4个线性布局

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

    <LinearLayout android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/linearLayout1" 
    android:background="@drawable/background"> 
    </LinearLayout> 
    <LinearLayout android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/linearLayout2" 
    android:background="@drawable/background_ass"> 
    </LinearLayout> 

<LinearLayout android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/linearLayout3" 
    android:background="@drawable/background"> 
    </LinearLayout> 

    <LinearLayout android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/linearLayout4" 
    android:background="@drawable/background_ass"> 
    </LinearLayout> 

</LinearLayout> 
+2

你怎么知道它是只显示第2?你在所有4个内部布局中使用相同的2个背景。 –

+0

4个背景有一个边框......我已经能够通过现在的图形化布局工具调整它们的大小,但它不适合太清楚,当我改变尺寸从QVGA向上:( – Ryan

+0

嘿您的背景被命名为background_ass对不起,我只是曾做到这一点。矣。 – Jack

回答

1

你有没有尝试在4内部LinearLayouts上设置layout_weight为“1”?可能是这样的:

<?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="fill_parent" 
        android:layout_height="fill_parent" 
        android:layout_weight="1" 
        android:background="#fafafa"/> 
    <LinearLayout android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:layout_weight="1" 
        android:background="#000000"/> 
    <LinearLayout android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:layout_weight="1" 
        android:background="#fafafa"/> 
    <LinearLayout android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:layout_weight="1" 
        android:background="#000000"/> 
</LinearLayout> 

这应该共享布局之间的可用空间。

编辑建议XML

+0

都能跟得上,没有工作要么... http://pastebin.com/Bh89VGY7 – Ryan

+0

我更新了我的XML在我的答案,XML,我有ç确认工作。检查一下,看看它是否适合你。 – hooked82

0

我想这可能是因为你可能有太多的内容被显示在你的前两个线性布局,因此WRAP_CONTENT前两个布局占用了屏幕上太多的空间,尝试寻找到这一点。

+0

我已经能够立即调整其大小通过图形化布局工具,但它不适合太清楚,当我改变从QVGA尺寸的向上:( – Ryan

+0

嗯,检查XML。在DP指定的尺寸? –

+0

是的,它在DP,甚至试图chzning它沾 – Ryan