Recyclerview не показывает такие вещи, как на андроид студии выглядит - PullRequest
0 голосов
/ 11 июля 2019

enter image description here сильный текст Слева изображение моего телефона, а справа - студия Android.Я хочу знать, почему мой телефон не похож на Android Studio.

Мой item.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
    xmlns: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"
    android:layout_margin="20dp"
    app:cardBackgroundColor="@color/colorSecurity">

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:weightSum="1">

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="0.2"
                android:gravity="center">
                <ImageView
                    android:layout_width="40dp"
                    android:layout_height="40dp"
                    android:src="@mipmap/ic_database"/>
            </LinearLayout>

            <TextView
                android:id="@+id/tvOption"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="0.8"
                android:gravity="center_vertical"
                android:text="OPCIÓN 1"/>

        </LinearLayout>

</androidx.cardview.widget.CardView>

Мой переработчик в моем классе активности

recyclerOptions = findViewById(R.id.recyclerOptions);
        recyclerOptions.setHasFixedSize(true);
        LinearLayoutManager lm = new LinearLayoutManager(this);
        lm.setOrientation(RecyclerView.VERTICAL);
        recyclerOptions.setLayoutManager(lm);

1 Ответ

0 голосов
/ 11 июля 2019

в вашем элементе адаптера, класс .xml устанавливает высоту

android:layout_height="wrap_content"

ваш адаптер автоматически установит

...