我需要一个EditText来填充我的窗口高度。 我正在使用这个:
但我得到的只是一行EditText,一旦我在多行输入返回按钮上写东西,它将更长并可滚动。 我知道我可以设置行号,但在这种情况下它应该在不同的设备上工作,每个设备(我猜)有不同的行数。
如何强制它填充设备的高度?
有小费吗?
尝试使用(没有ScrollView):
尝试为EditText设置这个,我有同样的事情,这将工作。
你也可以使用这个来准确设置你需要多少行,
android:lines="number of Lines"
RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" >
在java代码中设置这个…..
ed1 = (EditText) findViewById(R.id.editText1); ed1.setMovementMethod(new ScrollingMovementMethod()); <--------
将在所有设备中工作。
希望这会帮助你。
我的代码对我有用。
如果你可以在代码中添加它,就像这样:
EditText et = new EditText(this); l.addView(et, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, 100));
其中100
意味着它将具有100dp的宽度。 l
是您可以使用的Layout
(在您的情况下为ScrollView
),您可以使用R.layout.name_of_the_scroll_view
获取。
我不确定但是试着把WRAP_CONTENT
的高度属性WRAP_CONTENT
。