开发者

Android, getting 4 linear layouts

I am trying to get 4 linear layouts on the screen... but it only shows me the first two :(

(I'm a noob) here's my code:

<?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>


Have you tried setting the layout_weight to "1" on the 4 inner LinearLayouts? Possibly something like:

<?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>

This should share the available space between the layouts.

Edited proposed XML


I think this might be because you might have too much content being shown in your first two linear layouts. Hence wrap_content for the first two layouts is taking up too much space on the screen. Try looking into that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜