I want to make my RecyclerView as in VK, so that there are no CardView and indents around the edges in CardView .

Specifically, what would the article reached the side walls and there was a gap between the articles.

Where to read about it? or tell me how to do it?

enter image description here

    1 answer 1

    You are confusing margins and paddings .

    Fields (of this element) is the distance between the border of the parent element and the border of the given (child) element.

    Indents (of a given element) is the distance between the border of a given element and the border of its children.

    You need to remove the fields (left and right) from the CardView widget.

    The simplest CardView widget can be built like this:

     <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:layout_width="match_parent"> 

    Now add to this the CardView fields ( margins ) above and below:

     <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:layout_width="match_parent" android:layout_marginTop="4dp" android:layout_marginBottom="4dp"> 

    And remove the rounding corners:

     <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/apk/res-auto" android:layout_height="wrap_content" android:layout_width="match_parent" android:layout_marginTop="4dp" android:layout_marginBottom="4dp" card_view:cardCornerRadius="0dp"> 

    It will look like this (for clarity, I added CardView LinearLayout inside with two TextView ):

    enter image description here

    It seems like it turned out exactly what you need.