LorenzoBerti
LorenzoBerti

Reputation: 6974

Height Wrap content in RecyclerView not work even Android Support Library 23.2

I have update my library in gradle to com.android.support:recyclerview-v7:23.2.1 and I have this RecyclerView in my XML file.

<android.support.v7.widget.RecyclerView
                android:id="@+id/activityRecicler"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="15dp"
                />

And the layout Row is:

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


    <TextView
        android:layout_width="150dp"
        android:layout_height="wrap_content"
        android:id="@+id/activity"
        android:textStyle="bold"
        android:layout_weight="0.5"
        android:text="description"
        />

    <TextView
        android:id="@+id/hours"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@android:color/black"
        android:layout_weight="0.2"
        android:padding="8dp"
        />
    <Button
        android:id="@+id/deleteRow"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0.3"
        android:text="delete"
        />

But my TextView with id "description" is still hidden in part when is too long.

Upvotes: 0

Views: 1066

Answers (2)

Sangram Haladkar
Sangram Haladkar

Reputation: 717

In layout_row, add below code.

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


    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:id="@+id/activity"
        android:textStyle="bold"
        android:layout_weight="1"
        android:text="description"
        />

    <TextView
        android:id="@+id/hours"
       android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:textColor="@android:color/black"
        android:layout_weight="1"
        android:padding="8dp"
        />
    <Button
        android:id="@+id/deleteRow"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="delete"
        />

Upvotes: 1

spencer
spencer

Reputation: 454

Try changing your TextView attribute layout_width to wrap_content

<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/activity"
        android:textStyle="bold"
        android:layout_weight="0.5"
        android:text="descriptions"
        />

Upvotes: 0

Related Questions