CardView не отображается на API21 - PullRequest
0 голосов
/ 05 июня 2018

Я пытался создать CardView в своем приложении, но моя главная проблема заключается в том, что cardView не отображается на моем телефоне с API21, а отображается правильно в эмуляторе (API27).

Яне очень в Android, поэтому я не мог понять, где проблема и как я могу ее исправить.

Вот изображение того, как выглядит эмулятор и телефон enter image description here Пока вот мой XML-код этого макета:

<RelativeLayout 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"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context=".MainActivity">


    <GridLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@id/rellay_LOAD"
        android:alignmentMode="alignMargins"
        android:columnCount="2"
        android:columnOrderPreserved="false"
        android:rowCount="4">


        <!-- Row 1 -->
        <!--Column 1 -->

        <android.support.v7.widget.CardView
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_columnWeight="1"
            android:layout_marginBottom="2dp"
            android:layout_marginEnd="2dp"
            android:layout_marginStart="2dp"
            android:layout_marginTop="2dp"
            android:layout_rowWeight="1"
            app:cardElevation="0.50dp">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_margin="4dp"
                android:gravity="center_horizontal|center_vertical"
                android:orientation="vertical">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="CAFFE"
                    android:textAlignment="center"
                    android:textColor="@android:color/black"
                    tools:ignore="HardcodedText" />


            </LinearLayout>

        </android.support.v7.widget.CardView>

        <!--Column 2 -->

        <android.support.v7.widget.CardView
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_columnWeight="1"
            android:layout_marginBottom="2dp"
            android:layout_marginEnd="2dp"
            android:layout_marginStart="2dp"
            android:layout_marginTop="2dp"
            android:layout_rowWeight="1"
            app:cardElevation="0.50dp">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_margin="4dp"
                android:gravity="center_horizontal|center_vertical"
                android:orientation="vertical">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="CAFFE"
                    android:textAlignment="center"
                    android:textColor="@android:color/black"
                    tools:ignore="HardcodedText" />


            </LinearLayout>

        </android.support.v7.widget.CardView>

        <!-- Row 2 -->
        <!--Column 1 -->

        <android.support.v7.widget.CardView
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_columnWeight="1"
            android:layout_marginBottom="2dp"
            android:layout_marginEnd="2dp"
            android:layout_marginStart="2dp"
            android:layout_marginTop="2dp"
            android:layout_rowWeight="1"
            app:cardElevation="0.50dp">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_margin="4dp"
                android:gravity="center_horizontal|center_vertical"
                android:orientation="vertical">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="CAFFE"
                    android:textAlignment="center"
                    android:textColor="@android:color/black"
                    tools:ignore="HardcodedText" />


            </LinearLayout>

        </android.support.v7.widget.CardView>

        <!--Column 2 -->

        <android.support.v7.widget.CardView
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_columnWeight="1"
            android:layout_marginBottom="2dp"
            android:layout_marginEnd="2dp"
            android:layout_marginStart="2dp"
            android:layout_marginTop="2dp"
            android:layout_rowWeight="1"
            app:cardElevation="0.50dp">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_margin="4dp"
                android:gravity="center_horizontal|center_vertical"
                android:orientation="vertical">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="CAFFE"
                    android:textAlignment="center"
                    android:textColor="@android:color/black"
                    tools:ignore="HardcodedText" />


            </LinearLayout>

        </android.support.v7.widget.CardView>

        <!-- Row 3 -->
        <!--Column 1 -->

        <android.support.v7.widget.CardView
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_columnWeight="1"
            android:layout_marginBottom="2dp"
            android:layout_marginEnd="2dp"
            android:layout_marginStart="2dp"
            android:layout_marginTop="2dp"
            android:layout_rowWeight="1"
            app:cardElevation="0.50dp">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_margin="4dp"
                android:gravity="center_horizontal|center_vertical"
                android:orientation="vertical">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="CAFFE"
                    android:textAlignment="center"
                    android:textColor="@android:color/black"
                    tools:ignore="HardcodedText" />


            </LinearLayout>

        </android.support.v7.widget.CardView>

        <!--Column 2 -->

        <android.support.v7.widget.CardView
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_columnWeight="1"
            android:layout_marginBottom="2dp"
            android:layout_marginEnd="2dp"
            android:layout_marginStart="2dp"
            android:layout_marginTop="2dp"
            android:layout_rowWeight="1"
            app:cardElevation="0.50dp">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_margin="4dp"
                android:gravity="center_horizontal|center_vertical"
                android:orientation="vertical">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="CAFFE"
                    android:textAlignment="center"
                    android:textColor="@android:color/black"
                    tools:ignore="HardcodedText" />


            </LinearLayout>

        </android.support.v7.widget.CardView>

        <!-- Row 4 -->
        <!--Column 1 -->

        <android.support.v7.widget.CardView
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_columnWeight="1"
            android:layout_marginBottom="2dp"
            android:layout_marginEnd="2dp"
            android:layout_marginStart="2dp"
            android:layout_marginTop="2dp"
            android:layout_rowWeight="1"
            app:cardElevation="0.50dp">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_margin="4dp"
                android:gravity="center_horizontal|center_vertical"
                android:orientation="vertical">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="CAFFE"
                    android:textAlignment="center"
                    android:textColor="@android:color/black"
                    tools:ignore="HardcodedText" />


            </LinearLayout>

        </android.support.v7.widget.CardView>

        <!--Column 2 -->

        <android.support.v7.widget.CardView
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_columnWeight="1"
            android:layout_marginBottom="2dp"
            android:layout_marginEnd="2dp"
            android:layout_marginStart="2dp"
            android:layout_marginTop="2dp"
            android:layout_rowWeight="1"
            app:cardElevation="0.50dp">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_margin="4dp"
                android:gravity="center_horizontal|center_vertical"
                android:orientation="vertical">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="CAFFE"
                    android:textAlignment="center"
                    android:textColor="@android:color/black"
                    tools:ignore="HardcodedText" />


            </LinearLayout>

        </android.support.v7.widget.CardView>


    </GridLayout>


    <RelativeLayout
        android:id="@+id/rellay_LOAD"
        android:layout_width="match_parent"
        android:layout_height="97dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentStart="true"
        android:layout_centerInParent="true"
        android:layout_weight="0.65"
        android:background="@color/colorWhite"
        android:clickable="true"
        android:focusable="true"
        android:foreground="?attr/selectableItemBackground"
        tools:ignore="NestedWeights,ObsoleteLayoutParam">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            tools:ignore="UselessParent">


            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="5dp"
                android:text="CREATE"
                android:textSize="14sp"
                tools:ignore="HardcodedText" />

        </RelativeLayout>

    </RelativeLayout>

</RelativeLayout>
...