zl程序教程

您现在的位置是:首页 >  其它

当前栏目

EditText嵌套到ScrollView中时无法完全铺满

无法 完全 嵌套 EditText ScrollView
2023-09-27 14:27:30 时间

问题描述

单独EditText时,可以完全铺满父控件,但是放到ScroolView后,就缩成一行了.

解决方案

在ScrollView中增加android:fillViewport="true".
如:

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:fillViewport="true">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@null"
        android:gravity="top"
        android:inputType="textMultiLine" />

</ScrollView>