Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android LinearLayout within LinearLayout?

Tags:

android

I tried to make a simple layout like so

<?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:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="hello" />

    </LinearLayout>

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="world" />

</LinearLayout>

Only the first TextView ("hello") is displayed. What am I doing wrong?

like image 352
Jake Wilson Avatar asked Dec 12 '22 09:12

Jake Wilson


2 Answers

Make layout_height of inner layout wrap_content.

like image 70
anujprashar Avatar answered Jan 09 '23 11:01

anujprashar


Your second LinearLayout is set to fill_parent in the layout's height. This is causing it to push out everything that's below it that was placed into the first LinearLayout. Change it to wrap_content and it should work.

like image 38
DeeV Avatar answered Jan 09 '23 11:01

DeeV