GridLayout无法播放

问题描述 投票:1回答:1

我正在使用在API 26上可以找到的GridLayout,但是当我尝试使用22 API的电话时,它仅显示导航抽屉和空白屏幕。我正在将此依赖性用于cardview

实现'com.google.android.material:material:1.1.0'

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">


        <GridLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:alignmentMode="alignMargins"
            android:columnCount="2"
            android:padding="16dp"
            android:rowCount="3">

            <androidx.cardview.widget.CardView
                android:id="@+id/ortho_docs"
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:layout_rowWeight="1"
                android:layout_columnWeight="1"
                android:layout_marginStart="16dp"
                android:layout_marginEnd="16dp"
                android:layout_marginBottom="16dp"
                android:foreground="?android:attr/selectableItemBackground"
                app:cardCornerRadius="8dp"
                app:cardElevation="5dp">

                <LinearLayout style="@style/grid_cards">
                    <ImageView
                        android:layout_width="60dp"
                        android:layout_height="60dp"
                        android:layout_gravity="center_horizontal"
                        android:src="@drawable/ic_orthopedics" />
                    <TextView
                        style="@style/dept_headers"
                        android:text="@string/ortho" />
                </LinearLayout>
            </androidx.cardview.widget.CardView>
</GridLayout>


    </RelativeLayout>

    <com.google.android.material.navigation.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        app:headerLayout="@layout/navigation_header"
        app:itemIconTint="@color/colorPrimary"
        app:menu="@menu/menu">
    </com.google.android.material.navigation.NavigationView>
</androidx.drawerlayout.widget.DrawerLayout>
android xml android-cardview android-gridlayout
1个回答
0
投票

尝试使用androidx.gridlayout.widget.GridLayout

您可能需要将此添加到gradle implementation 'androidx.gridlayout:gridlayout:1.0.0-rc01'

© www.soinside.com 2019 - 2024. All rights reserved.