0

Не могу понять, почему между элементами такое большое расстояние. Вроде бы всё делаю согласно руководствам из Интернета.

Код карточки:

<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>

код активити

<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"/>

взято отсюда

3
  • а в коде вы ничего с view-ми не делаете?
    – s_klepcha
    22 сен 2016 в 18:10
  • Это у вас в графическом редакторе студии такое? На девайсе пробовали? Там всё нормально должно быть.
    – ЮрийСПб
    22 сен 2016 в 19:12
  • 1
    <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
    22 сен 2016 в 19:50

1 ответ 1

0

действительно, ступил. свитер-про был прав. выставил android:layout_height="wrap_content" и все встало как надо

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.