NeoKerd
NeoKerd

Reputation: 219

Height of linearlayout in android studio

I have a problem with my linear layouts. There is two linear layout vertical in a horizontal parents, the first one dont take the same height of the second.

There is my LinearLayout :

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">


    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:background="@android:color/darker_gray">
        <TextView
            android:id="@+id/nomPers"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Nom User"
            android:textColor="@android:color/black"
            android:textAppearance="?android:attr/textAppearanceMedium"/>

        <TextView
            android:id="@+id/dateVisite"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:lines="1"
            android:ellipsize="end"
            android:text="Date"
            android:textColor="@android:color/black"
            android:textAppearance="?android:attr/textAppearanceMedium"/>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">


        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:text="Type de visite"
            android:id="@+id/typeVisteCli"
            android:textColor="@android:color/black"
            android:layout_marginLeft="5dp"/>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:id="@+id/tv_list_obs_visite_cli"
            android:text="obs"
            android:textColor="@android:color/black"
            android:layout_marginLeft="5dp"/>


    </LinearLayout>


</LinearLayout>

And a screen of what i have :

enter image description here

You can see that the gray dont fill the entire linearLayout. Thx.


EDIT

I'm really sorry i put the wrong LinearLayout ...

Upvotes: 1

Views: 1178

Answers (3)

Karan Mehta
Karan Mehta

Reputation: 1541

Try this :

<LinearLayout android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    xmlns:android="http://schemas.android.com/apk/res/android">


    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:background="@android:color/darker_gray">
        <TextView
            android:id="@+id/nomPers"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Nom User"
            android:textColor="@android:color/black"
            android:textAppearance="?android:attr/textAppearanceMedium"/>

        <TextView
            android:id="@+id/dateVisite"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:lines="1"
            android:ellipsize="end"
            android:text="Date"
            android:textColor="@android:color/black"
            android:textAppearance="?android:attr/textAppearanceMedium"/>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">


        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:text="Type de visite"
            android:id="@+id/typeVisteCli"
            android:textColor="@android:color/black"
            android:layout_marginLeft="5dp"/>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:id="@+id/tv_list_obs_visite_cli"
            android:text="obs"
            android:textColor="@android:color/black"
            android:layout_marginLeft="5dp"/>


    </LinearLayout>


</LinearLayout>

Upvotes: 1

Pritesh Parmar
Pritesh Parmar

Reputation: 83

Try this one.I am changing your code.

<?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="wrap_content"
    android:orientation="horizontal">

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:background="@android:color/darker_gray">
            <TextView
                android:id="@+id/date_ti_cli"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:lines="1"
                android:ellipsize="end"
                android:text="Date"
                android:textColor="@android:color/black"
                android:textAppearance="?android:attr/textAppearanceMedium"/>
            <TextView
                android:id="@+id/nomPers_ti_cli"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:text="Nom User"
                android:textColor="@android:color/black"
                android:textAppearance="?android:attr/textAppearanceMedium"/>

        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Observation"
                android:textColor="@android:color/black"
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:layout_marginLeft="5dp"
                android:id="@+id/tv_list_obs_ti_cli"/>

        </LinearLayout>

</LinearLayout>

Upvotes: 1

ashok
ashok

Reputation: 429

You have wrote wrap_content in second linear layout height.You should change it with match_parent.

Upvotes: 1

Related Questions