Skip to content Skip to sidebar Skip to footer

Items In Recyclerview Doesn't Take The Full Width

I am new in android development i make a recyclerview but I have a problem when using the RecyclerView , an item doesn't take the full width in the screen I don't know what's the p

Solution 1:

Don't use specified dp to layout_height and layout_width. You must set your recyclerview's width to match_parent

<android.support.v7.widget.RecyclerView
    android:id="@+id/recyclerId"
    android:layout_width="match_parent"//This line
    android:layout_height="495dp"
    tools:layout_editor_absoluteY="16dp"
    android:layout_marginRight="8dp"//Also remove this line...
    app:layout_constraintRight_toRightOf="parent" />

Solution 2:

Fixed measures are a bad pratice. in your main activity, change to:

<android.support.v7.widget.RecyclerViewandroid:id="@+id/recyclerId"android:layout_width="match_parent" <!--THISLINE-->
        android:layout_height="match_parent"<!--THIS LINE or wrap_content-->
        tools:layout_editor_absoluteY="16dp"
        android:layout_marginRight="0dp"<!--why it was 8? obviously it wont work-->
        app:layout_constraintRight_toRightOf="parent" />

Post a Comment for "Items In Recyclerview Doesn't Take The Full Width"