CardView在我的Android应用程序中运行不正常,在屏幕上显示不同

问题描述 投票:0回答:3

我正在使用带有match_parent和wrap_content的android.support.v7.widget.CardView。我想让我的布局响应所有设备。一切都在Android工作室正常工作。但是当我将这个应用程序安装到Android设备或模拟器时,它显示如下图像。

但我想让它响应宽度和高度。请帮我解决这个问题。

我的片段代码是:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <LinearLayout
        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"
        android:background="@color/colorBG"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        tools:context=".LiveTV"
        android:padding="10dp"
        android:orientation="vertical">

        <!-- TODO: Update blank fragment layout -->

        <LinearLayout
            android:clipToPadding="false"
            android:gravity="center"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.CardView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_columnWeight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_rowWeight="1"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/news24"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/news24"
                        android:padding="10dp"/>

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

            <android.support.v7.widget.CardView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_columnWeight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_rowWeight="1"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/deshebideshe"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/deshebideshe"
                        android:padding="10dp"/>
                </LinearLayout>
            </android.support.v7.widget.CardView>
        </LinearLayout>


        <LinearLayout
            android:clipToPadding="false"
            android:gravity="center"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.CardView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_columnWeight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_rowWeight="1"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/jamuna"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/jamuna"
                        android:padding="10dp"/>

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

            <android.support.v7.widget.CardView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_columnWeight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_rowWeight="1"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/satv"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/satv"
                        android:padding="10dp"/>
                </LinearLayout>
            </android.support.v7.widget.CardView>
        </LinearLayout>

        <LinearLayout
            android:clipToPadding="false"
            android:gravity="center"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.CardView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_columnWeight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_rowWeight="1"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/jagobanglatv"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/jagobanglatv"
                        android:padding="10dp"/>

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

            <android.support.v7.widget.CardView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_columnWeight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_rowWeight="1"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/nrbtv"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/nrbtv"
                        android:padding="10dp"/>
                </LinearLayout>
            </android.support.v7.widget.CardView>
        </LinearLayout>

        <LinearLayout
            android:clipToPadding="false"
            android:gravity="center"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.CardView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_columnWeight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_rowWeight="1"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/rtvmusic"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/rtvmusic"
                        android:padding="10dp"/>

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

            <android.support.v7.widget.CardView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_columnWeight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_rowWeight="1"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/qtv"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/qtv"
                        android:padding="10dp"/>
                </LinearLayout>
            </android.support.v7.widget.CardView>
        </LinearLayout>

        <LinearLayout
            android:clipToPadding="false"
            android:gravity="center"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.CardView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_columnWeight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_rowWeight="1"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/panvisiontv"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/panvisiontv"
                        android:padding="10dp"/>

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

            <android.support.v7.widget.CardView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_columnWeight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_rowWeight="1"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/millennium"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/millennium"
                        android:padding="10dp"/>
                </LinearLayout>
            </android.support.v7.widget.CardView>
        </LinearLayout>

        <LinearLayout
            android:clipToPadding="false"
            android:gravity="center"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.CardView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_columnWeight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_rowWeight="1"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/btvworld"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/btvworld"
                        android:padding="10dp"/>

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

            <android.support.v7.widget.CardView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_columnWeight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_rowWeight="1"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/probashibangla"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/probashibangla"
                        android:padding="10dp"/>
                </LinearLayout>
            </android.support.v7.widget.CardView>
        </LinearLayout>


    </LinearLayout>

</android.support.v4.widget.NestedScrollView>

谢谢。

android android-layout android-fragmentactivity android-cardview cardview
3个回答
0
投票

在卡片视图中进行以下更改

  • 使CardViewandroid:layout_width="0dp"
  • 在你的android:layout_weight="1"中使用CardView

试试这个

   <?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <LinearLayout
        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"
        android:background="@color/colorBG"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        tools:context=".LiveTV"
        android:padding="10dp"
        android:orientation="vertical">

        <!-- TODO: Update blank fragment layout -->

        <LinearLayout
            android:clipToPadding="false"
            android:gravity="center"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.CardView
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="wrap_content"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/news24"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/news24"
                        android:padding="10dp"/>

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

            <android.support.v7.widget.CardView
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="wrap_content"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/deshebideshe"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/deshebideshe"
                        android:padding="10dp"/>
                </LinearLayout>
            </android.support.v7.widget.CardView>
        </LinearLayout>


        <LinearLayout
            android:clipToPadding="false"
            android:gravity="center"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.CardView
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="wrap_content"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/jamuna"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/jamuna"
                        android:padding="10dp"/>

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

            <android.support.v7.widget.CardView
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="wrap_content"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/satv"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/satv"
                        android:padding="10dp"/>
                </LinearLayout>
            </android.support.v7.widget.CardView>
        </LinearLayout>

        <LinearLayout
            android:clipToPadding="false"
            android:gravity="center"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.CardView
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="wrap_content"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/jagobanglatv"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/jagobanglatv"
                        android:padding="10dp"/>

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

            <android.support.v7.widget.CardView
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="wrap_content"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"

                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/nrbtv"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/nrbtv"
                        android:padding="10dp"/>
                </LinearLayout>
            </android.support.v7.widget.CardView>
        </LinearLayout>

        <LinearLayout
            android:clipToPadding="false"
            android:gravity="center"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.CardView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/rtvmusic"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/rtvmusic"
                        android:padding="10dp"/>

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

            <android.support.v7.widget.CardView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/qtv"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/qtv"
                        android:padding="10dp"/>
                </LinearLayout>
            </android.support.v7.widget.CardView>
        </LinearLayout>

        <LinearLayout
            android:clipToPadding="false"
            android:gravity="center"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.CardView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_weight="1"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/panvisiontv"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/panvisiontv"
                        android:padding="10dp"/>

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

            <android.support.v7.widget.CardView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/millennium"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/millennium"
                        android:padding="10dp"/>
                </LinearLayout>
            </android.support.v7.widget.CardView>
        </LinearLayout>

        <LinearLayout
            android:clipToPadding="false"
            android:gravity="center"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.CardView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/btvworld"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/btvworld"
                        android:padding="10dp"/>

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

            <android.support.v7.widget.CardView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                app:cardCornerRadius="8dp"
                app:cardElevation="8dp"
                android:layout_margin="10dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:gravity="center">

                    <ImageView
                        android:id="@+id/probashibangla"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/probashibangla"
                        android:padding="10dp"/>
                </LinearLayout>
            </android.support.v7.widget.CardView>
        </LinearLayout>


    </LinearLayout>

</android.support.v4.widget.NestedScrollView>

BTW

根据我的建议,你可以使用qazxsw poi和qazxsw poi

这是关于如何使用RecyclerView的好文章


0
投票

在linearLayout中添加这些行,它们有两个cardView

GridLayoutManager

并在cardView中添加此行

RecyclerView with GridLayoutManager

并使cardView width 0dp像这样

android:weightSum="2"

0
投票

我认为你的cardview看起来并不完美,因为图像的大小,我想如果你使用recyclerview和gridlayoutmanager的适配器将解决你的问题

android:layout_weight="1"

在顶部代码中如果你把2而不是numberofColumns放在每一行就会放两个cardivew它会解决你的问题,

如果您不想使用recyclerview,您应该给出尺寸 android:layout_width和android:layout_height的imageView然后使xml布局在6个不同的通常大小

hdpi,xhdpi,xxhdpi,xxxhdpi,sw600dp和sw720dp

它看起来不是一个好的解决方案

我希望它可以帮到你(:

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