首页 > 解决方案 > 来自 ScrollView -> 相对布局的内容未显示

问题描述

我希望我的内容显示在此 ScrollView 中。此 ScrollView 在 CardView 中。

<android.support.v7.widget.CardView
        android:id="@+id/card_name"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_columnWeight="1"
        android:layout_rowWeight="1"
        android:layout_marginBottom="15dp"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp"
        app:cardElevation="10dp"
        app:cardBackgroundColor="#CCffffff"
        app:cardCornerRadius="10dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_margin="15dp"
            android:layout_height="match_parent">

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_gravity="top|center"
                android:layout_height="match_parent">

                <TextView
                    android:id="@+id/textviewhead"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textColor="@color/colorAccent"
                    android:textSize="20dp"
                    android:textStyle="bold"
                    tools:text="..." />

                <TextView
                    android:id="@+id/textviewinfo"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/textviewhead"
                    android:layout_marginTop="5dp"
                    android:textColor="@color/colorAccent"
                    android:textSize="16dp"
                    tools:text="..." />

                <TextView
                    android:id="@+id/textviewinfo2"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/textviewinfo"
                    android:layout_marginTop="5dp"
                    android:textColor="@color/colorAccent"
                    android:textSize="16dp"
                    tools:text="..." />
            </RelativeLayout>

        </ScrollView>

        </LinearLayout>

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

我也在没有 LinearLayout 的情况下尝试过,但这对我不起作用。在 AndroidStudio 的预览中,内容也会显示出来,您也可以滚动。当我在模拟器或手机上尝试整个过程时,你只会看到白色的 CardView。我还尝试将“match_parent”更改为“wrap_content”,但我的手机仍然没有显示任何内容。

我希望有人可以帮助我解决这个问题。亲切的问候

杰尔

标签: androidandroid-studioscrollviewandroid-cardview

解决方案


推荐阅读