Gridlayout正在显示4条记录,但是在我更改rowCount并增加到6条之后,它未在android中显示

问题描述

Gridlayout显示4条记录,但是在我更改rowCount并增加到6之后,它在android中没有显示。 我使用此代码显示了4行的网格布局,并且可以工作,但是当我增加到6行时,它不再显示enter image description here

<androidx.constraintlayout.widget.ConstraintLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            >
            <GridLayout
                android:id="@+id/gridLayout1"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_marginTop="10dp"
                android:alignmentMode="alignBounds"
                android:columnCount="2"
                android:padding="5dp"
                android:rowCount="6"
                app:layout_constraintStart_toStartOf="@+id/guideline6"
                app:layout_constraintTop_toBottomOf="@+id/textWelcome1"
                app:layout_constraintVertical_bias="0.0"
                app:layout_editor_absoluteX="0dp">
        
                <RelativeLayout
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_rowWeight="1"
                    android:layout_columnWeight="1"
                    android:layout_marginLeft="15dp"
                    android:layout_marginBottom="16dp">
        
                    <com.makeramen.roundedimageview.RoundedImageView
                        android:id="@+id/img"
                        android:layout_width="180dp"
                        android:layout_height="240dp"
                        android:scaleType="centerCrop"
                        android:src="@mipmap/first"
                        app:riv_corner_radius="10dp" />
        
                    <TextView
                        android:id="@+id/description"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/img"
                        android:layout_gravity="center"
                        android:layout_margin="5dp"
                        android:fontFamily="@font/noir_medium_reg"
                        android:text="Plantains and bananas"
                        android:textAlignment="center"
                        android:textColor="#555555"
                        android:textSize="15sp" />
        
                </RelativeLayout>
        
                <RelativeLayout
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_rowWeight="1"
                    android:layout_columnWeight="1"
                    android:layout_marginLeft="16.17dp"
                    android:layout_marginRight="15dp"
                    android:layout_marginBottom="16dp">
        
        
                    <com.makeramen.roundedimageview.RoundedImageView
                        android:id="@+id/img1"
                        android:layout_width="180dp"
                        android:layout_height="240dp"
                        android:scaleType="centerCrop"
                        android:src="@mipmap/second"
                        app:riv_corner_radius="10dp" />
        
                    <TextView
                        android:id="@+id/description1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/img1"
                        android:layout_gravity="center"
                        android:layout_margin="5dp"
                        android:fontFamily="@font/noir_medium_reg"
                        android:text="Salads and leaf greens"
                        android:textAlignment="center"
                        android:textColor="#555555"
                        android:textSize="15sp" />
        
                </RelativeLayout>
        
                <RelativeLayout
                    android:id="@+id/rel1"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_rowWeight="1"
                    android:layout_columnWeight="1"
                    android:layout_marginLeft="15dp"
                    android:layout_marginBottom="16dp">
        
                    <com.makeramen.roundedimageview.RoundedImageView
                        android:id="@+id/img2"
                        android:layout_width="180dp"
                        android:layout_height="240dp"
                        android:scaleType="centerCrop"
                        android:src="@mipmap/first"
                        app:riv_corner_radius="10dp" />
        
                    <TextView
                        android:id="@+id/description2"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/img2"
                        android:layout_gravity="center"
                        android:layout_margin="5dp"
                        android:fontFamily="@font/noir_medium_reg"
                        android:text="Tomatoes,onions and peppers"
                        android:textAlignment="center"
                        android:textColor="#555555"
                        android:textSize="15sp" />
        
                </RelativeLayout>
        
                <RelativeLayout
                    android:id="@+id/rel2"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_rowWeight="1"
                    android:layout_columnWeight="1"
                    android:layout_marginLeft="16.17dp"
                    android:layout_marginRight="15dp"
                    android:layout_marginBottom="16dp">
        
        
                    <com.makeramen.roundedimageview.RoundedImageView
                        android:id="@+id/img3"
                        android:layout_width="180dp"
                        android:layout_height="240dp"
                        android:scaleType="centerCrop"
                        android:src="@mipmap/second"
                        app:riv_corner_radius="10dp" />
        
                    <TextView
                        android:id="@+id/description3"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/img3"
                        android:layout_gravity="center"
                        android:layout_margin="5dp"
                        android:fontFamily="@font/noir_medium_reg"
                        android:text="Potatoes and yams"
                        android:textAlignment="center"
                        android:textColor="#555555"
                        android:textSize="15sp" />
        
                </RelativeLayout>
        
                <RelativeLayout
                    
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_rowWeight="1"
                    android:layout_columnWeight="1"
                    android:layout_marginLeft="15dp"
                    android:layout_marginBottom="16dp">
        
                    <com.makeramen.roundedimageview.RoundedImageView
                        android:id="@+id/img22"
                        android:layout_width="180dp"
                        android:layout_height="240dp"
                        android:scaleType="centerCrop"
                        android:src="@mipmap/first"
                        app:riv_corner_radius="10dp" />
        
                    <TextView
                        android:id="@+id/description22"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/img22"
                        android:layout_gravity="center"
                        android:layout_margin="5dp"
                        android:fontFamily="@font/noir_medium_reg"
                        android:text="Tomatoes,onions and peppers"
                        android:textAlignment="center"
                        android:textColor="#555555"
                        android:textSize="15sp" />
        
                </RelativeLayout>
        
                <RelativeLayout
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_rowWeight="1"
                    android:layout_columnWeight="1"
                    android:layout_marginLeft="16.17dp"
                    android:layout_marginRight="15dp"
                    android:layout_marginBottom="16dp">
        
        
                    <com.makeramen.roundedimageview.RoundedImageView
                        android:id="@+id/img33"
                        android:layout_width="180dp"
                        android:layout_height="240dp"
                        android:scaleType="centerCrop"
                        android:src="@mipmap/second"
                        app:riv_corner_radius="10dp" />
        
                    <TextView
                        android:id="@+id/description33"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/img33"
                        android:layout_gravity="center"
                        android:layout_margin="5dp"
                        android:fontFamily="@font/noir_medium_reg"
                        android:text="Potatoes and yams"
                        android:textAlignment="center"
                        android:textColor="#555555"
                        android:textSize="15sp" />
        
                </RelativeLayout>
    


            </GridLayout>
        </androidx.constraintlayout.widget.ConstraintLayout>

网格布局显示4条记录,但是在更改rowCount并增加到6之后,它在android中没有显示。 我用这段代码显示一个4行的网格布局,它可以工作,但是当我增加到6行时,它不再显示

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)