【问题标题】:ScrollView cuts last lines in TextViewScrollView 剪切 TextView 中的最后一行
【发布时间】:2020-08-13 19:48:08
【问题描述】:

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

<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>

【问题讨论】:

    标签: android textview scrollview


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-07-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-07
      • 1970-01-01
      • 1970-01-01
      • 2017-09-11
      相关资源
      最近更新 更多