小编mil*_*ana的帖子

带有 CardView 的 GridLayout 未显示在较低的操作系统版本中

我是在制造GridLayoutCardView用于自动定向cardview,高度和宽度cardview设置为0dp它在nougart工作的罚款和奥利奥,但没有工作LollipopKitkat。这是布局代码:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.help.MainActivity">

    <LinearLayout
        android:orientation="vertical"
        android:background="@drawable/bg"
        android:weightSum="10"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    <RelativeLayout
        android:layout_weight="2"
        android:layout_width="match_parent"
        android:layout_height="0dp">

        <TextView
            android:id="@+id/textGrid"
            android:text="GRID LAYOUT"
            android:textSize="34sp"
            android:textColor="@android:color/white"
            android:layout_centerInParent="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

    </RelativeLayout>

    <GridLayout
        android:id="@+id/mainGrid"
        android:columnCount="2"
        android:rowCount="3"
        android:alignmentMode="alignMargins"
        android:columnOrderPreserved="false"
        android:layout_weight="8"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:padding="14dp"
        >

        <!-- Row 1 -->

        <!-- Column 1 -->
        <android.support.v7.widget.CardView
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_columnWeight="1"
            android:layout_rowWeight="1"
            android:layout_marginBottom="16dp"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            app:cardElevation="8dp"
            app:cardCornerRadius="8dp"
            >

            <LinearLayout
                android:layout_gravity="center_horizontal|center_vertical"
                android:layout_margin="16dp"
                android:orientation="vertical"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"> …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-gridlayout android-studio android-cardview

0
推荐指数
1
解决办法
4994
查看次数