我需要一个填充窗口高度的 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/