Android - EditText 多行强制填充高度

标签 android android-edittext scrollview multiline fill-parent

我需要一个填充窗口高度的 EditText。 我正在使用这个:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >

<EditText
    android:id="@+id/text_editor"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:background="#ff0000"
    android:gravity="top|left"
    android:inputType="textMultiLine"
    android:textColor="@android:color/white" />

</ScrollView>

但我得到的只是一行 EditText,一旦我在多行上输入内容并键入返回按钮,它就会变得更长且可滚动。 我知道我可以设置行号,但在这种情况下,它应该适用于不同的设备,并且每个设备(我猜)都有不同的行数。

如何强制它在高度上填满设备?

有什么建议吗?

最佳答案

尝试使用(没有ScrollView):

<EditText
    android:id="@+id/text_editor"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:background="#ff0000"
    android:gravity="top|left"
    android:textColor="@android:color/white" />

关于Android - EditText 多行强制填充高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11120879/

相关文章:

java - Android 的 AudioRecord 类以什么顺序存储音频样本?

android - phoneauthprovider 的 oncodesent 不工作

java - 在本地主机上使用 nanohttpd 作为服务器,如何在整个目录中提供静态 HTML 代码?

android - 如何使用 EditText 在 Android 中检索字符串?

java - 类型 View 的 setText 方法字符串未定义

Android 水平滚动条正在剪切文本

Android在进度条加载完成后隐藏标题栏

java - 实时格式化 Android EditText 时如何避免 StackOverflow?

Angular 虚拟滚动跳跃

android-layout - 如何解决包含具有layout_gravity ="center"子级的ScrollView的错误