开发者

LinearLayout is hidden behind the first LinearLayout

My first LinearLayout is being displayed correctly but the second LinearLayout gets hidden behind the first one. Here is the sample code that I use.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    >
        <LinearLayout android:id="@+id/linearLayout1" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_width="wrap_content">
            <LinearLayout android:id="@+id/linearLayout11" android:baselineAligned="false" android:layout_height="wrap_content" android:paddingRight="70px" android:paddingTop="40px" android:orientation="horizontal" android:paddingLeft="10px" android:layout_width="wrap_content">
                <ImageView android:id="@+id/imageView111" android:layout_height="wrap_content" android:src="@drawable/home" android:clickable="true" android:layout_width="wrap_content"></ImageView>
            </LinearLayout>
            <LinearLayout android:id="@+id/linearLayout12" android:layout_height="wrap_content" android:paddingRight="70px" android:paddingTop="40px" android:orientation="vertical" android:paddingLeft="70px" android:layout_width="wrap_content">
                <ImageView android:id="@+id/imageView121" android:layout_height="wrap_content" android:src="@drawable/email" android:clickable="true" android:layout_width="wrap_content"></ImageView>
            </LinearLayout>
            <LinearLayout android:id="@+id/linearLayout13" android:layout_height="wrap_content" android:paddingRight="70px" android:orientation="vertical" android:paddingLeft="70px" android:layout_width="wrap_content">
                <ImageView android:id="@+id/imageView131" android:layout_height="wrap_content" android:src="@drawable/baby" android:clickable="true" android:layout_width="wrap_content"></ImageView>
            </LinearLayout>
            <LinearLayout android:id="@+id/linearLayout14" android:layout_height="wrap_content" android:paddingRight="70px" android:paddingTop="40px" android:orientation="vertical" android:paddingLeft="60px" android:layout_width="wrap_content">
                <ImageView android:id="@+id/imageView141" android:layout_height="wrap_content" android:src="@drawable/camera" android:clickable="true" android:layout_width="wrap_content"></ImageView>
            </LinearLayout>
            <LinearLayout android:id="@+id/linearLayout15" android:layout_height="wrap_content" android:paddingRight="10px" android:paddingTop="40px" android:orientation="vertical" android:paddingLeft="10px" android:layout_width="wrap_content">
                <ImageView android:id="@+id/imageView151" android:layout_height="wrap_content" android:src="@drawable/settings" android:clickable="true" android:layout_width="wrap_content"></ImageView>
            </LinearLayout>
        </LinearLayout>
        <LinearLayout android:id="@+id/linearLayout2" android:layout_height="wrap_content" android:paddingTop="500px" android:orientation="horizontal" android:layout_width="wrap_content">
            <LinearLayout android:id="@+id/linearLayout21" android:layout_height="wrap_content" android:paddingRight="70px" android:paddingLeft="10px" android:layout_width="wrap_content">
                <TextView android:id="@+id开发者_C百科/textView211" android:textSize="20px" android:layout_height="wrap_content" android:text="In-Hospital" android:layout_width="wrap_content"></TextView>
            </LinearLayout>
            <LinearLayout android:id="@+id/linearLayout22" android:layout_height="wrap_content" android:paddingRight="70px" android:paddingLeft="10px" android:layout_width="wrap_content">
                <TextView android:id="@+id/textView221" android:textSize="20px" android:layout_height="wrap_content" android:text="Home" android:layout_width="wrap_content"></TextView>
            </LinearLayout>
            <LinearLayout android:id="@+id/linearLayout23" android:layout_height="wrap_content" android:paddingRight="70px" android:paddingLeft="10px" android:layout_width="wrap_content">
                <TextView android:id="@+id/textView231" android:textSize="20px" android:layout_height="wrap_content" android:text="Nursing" android:layout_width="wrap_content"></TextView>
            </LinearLayout>
        </LinearLayout>
</LinearLayout>

Can anyone please tell me where I go wrong?

Thanks.


Your outer LinearLayout has an orientation of horizontal, this means that the second LinearLayout should be being displayed to the right of the other one, not below it. Try changing the orientation to vertical.

All of your pixel specific sizes are probably screwing things up as well. You should never use pixels to layout your file. If you really need to specify sizes, use dp. However, I really doubt that you need to be setting most any of those sizes explicitly.

If you explain what you are actually trying to do, we can help you further. Meanwhile, read through the docs on layouts. There is a lot of good info there, especially Supporting Multiple Screens.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜