【问题标题】:GridLayout doesn't apperGridLayout 没有出现
【发布时间】:2020-10-05 21:26:02
【问题描述】:

我正在使用这个GridLayout,它可以在 api 26 上找到,但是当我在 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】:

    尝试使用androidx.gridlayout.widget.GridLayout

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

    【讨论】:

    • androidx.gridlayout:gridlayout:1.0.0 自此日期起发布,因此您也可以使用它代替此候选版本
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-12-07
    • 1970-01-01
    • 2014-04-05
    • 2015-08-30
    • 1970-01-01
    • 2021-02-11
    • 2015-01-19
    相关资源
    最近更新 更多