ScrollView 剪切 TextView 中的最后一行

ScrollView cuts last lines in TextView

我对 ScrollView 有疑问。在像 480x800 这样的非常小的屏幕上,TextView 被 ScrollView 剪切,它不会滚动到最后。我认为它削减了 2-3 最后一行并且 scrollview 无法测量全高。在普通屏幕上效果很好。我的代码看起来像这样。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical">

<androidx.cardview.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:cardCornerRadius="10dp"
    android:layout_margin="5dp">

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

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="180dp"
            android:scaleType="centerCrop"
            android:id="@+id/image"
            android:src="@drawable/xyz"/>
        <View
            android:layout_width="match_parent"
            android:layout_height="2dp"
            android:alpha=".5"
            android:layout_above="@id/title"
            android:background="@android:color/darker_gray" />
        <TextView
            android:id="@+id/title"
            android:textColor="#262626"
            android:layout_below="@id/image"
            android:layout_marginTop="10dp"
            android:layout_marginStart="16dp"
            android:text="Title"
            android:textSize="20sp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>

            <ScrollView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/title"
                android:layout_marginTop="5dp"
                android:layout_gravity="center_vertical">
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">
                    <TextView
                        android:id="@+id/desc"
                        android:textSize="16sp"
                        android:fontFamily="@font/open_sans"
                        android:layout_marginLeft="16dp"
                        android:layout_marginBottom="16dp"
                        android:layout_marginRight="16dp"
                        android:drawablePadding="10dp"
                        android:ellipsize="end"
                        android:text="Description"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"/>
                </RelativeLayout>
            </ScrollView>
    </RelativeLayout>
</androidx.cardview.widget.CardView>

我找到了解决办法。只需将 RelativeLayout android:layout_height="530dp" 更改为 wrap_content 并将其设置为 CardView。