How To Set Initial Layout_width Of Cards In Recycler View To Match_parent?
I am facing issue with rendering items in recycler view. The problem happens with the items that are initially loaded as you can see in the pic below that layout width doesn't beco
Solution 1:
Finally found the answer after hours of digging...
Just replace:
<android.support.v7.widget.CardViewandroid:layout_width="match_parent"android:layout_height="match_parent"><TextViewandroid:id="@+id/textreplaced"android:layout_width="match_parent"android:layout_height="wrap_content"android:text="xyz" /><ImageViewandroid:layout_width="match_parent"android:layout_height="match_parent"android:src="@drawable/common_google_signin_btn_icon_dark" /></android.support.v7.widget.CardView>
by:
<?xml version="1.0" encoding="utf-8"?><RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"android:layout_width="match_parent"android:layout_height="60dp"app:cardBackgroundColor="@color/colorPrimary"><android.support.v7.widget.CardViewandroid:layout_width="match_parent"android:layout_height="match_parent"><TextViewandroid:id="@+id/textreplaced"android:layout_width="match_parent"android:layout_height="wrap_content"android:text="xyz" /><ImageViewandroid:layout_width="match_parent"android:layout_height="match_parent"android:src="@drawable/common_google_signin_btn_icon_dark" /></android.support.v7.widget.CardView></RelativeLayout>
Though I don't have any idea why it happened. So If anyone knows the reasoning he/she may post an answer for this and I will mark that as accepted answer as this one is just workaround.
Solution 2:
Try to put a view between the TextView and Button and set its width to match_parent
Post a Comment for "How To Set Initial Layout_width Of Cards In Recycler View To Match_parent?"