1

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

NeoKerd
  • 189
  • 3
  • 13
  • The same code is working perfectly, so there might be some problem with how you implement it in the recyclerview, so can you please share that code as well? – Karan Mehta Jan 21 '20 at 08:57
  • @KaranMehta i just realize that i have put the wrong linearLayout, i have edited the post, so sorry – NeoKerd Jan 21 '20 at 09:13
  • 1
    Hi @Neokerd i see some answers posted, If you don't see them working let me know i can help you out. – Manikanta Jan 21 '20 at 09:13
  • @Manikanta its ok now but i will come talk with u if i need help with android studio things :) – NeoKerd Jan 21 '20 at 09:20
  • Hi @Manikanta pls can u come help me on this point https://stackoverflow.com/questions/59842015/select-and-copy-text-in-a-textview-android – NeoKerd Jan 22 '20 at 08:11

3 Answers3

1

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

ashok
  • 431
  • 5
  • 8
1

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>
  • So sorry, ur answer make me realize that i've post the wrong linearlayout, thanks for ur answer – NeoKerd Jan 21 '20 at 09:14
1

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>
Karan Mehta
  • 1,442
  • 13
  • 32