I can not understand why there is such a long distance between the elements. It seems to be doing everything according to the manuals from the Internet.

Card code:

<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" android:id="@+id/card_view" android:layout_gravity="center" android:layout_width="310dp" android:layout_height="220dp" android:layout_marginBottom="5dp" card_view:cardCornerRadius="5dp" card_view:contentPadding="10dp" card_view:cardElevation="5dp"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/card_img"/> <TextView android:id="@+id/tv_recycler_item" android:layout_weight="1" android:layout_width="match_parent" android:layout_height="match_parent" /> </LinearLayout> </android.support.v7.widget.CardView> 

activation code

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity"> <android.support.v7.widget.RecyclerView android:id="@+id/my_recycler_view" android:scrollbars="vertical" android:layout_width="match_parent" android:layout_height="match_parent"/> 

taken from here

  • and in the code you do not do anything with view-mi? - s_klepcha
  • Is this in your studio graphic editor? On the device tried? Everything should be fine there. - Yuriy SPb
  • one
    <android.support.v7.widget.RecyclerView android: id = "@ + id / my_recycler_view" android: scrollbars = "vertical" android: layout_width = "match_parent" android: layout_height = "wrap_content" /> - sviter-pro

1 answer 1

really stepped. sweater pro was right. set android: layout_height = "wrap_content" and everything fell as it should