android+多种行视图,在Android的EditText视图中允许多行?

如何在Android的EditText视图中允许多行?

#1楼

这对我有用 ,实际上这两个属性很重要: inputType和lines 。 此外,您可能需要一个滚动条,下面的代码显示了如何制作一个:

android:id="@+id/addr_edittext"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:gravity="top|left"

android:inputType="textEmailAddress|textMultiLine"

android:lines="20"

android:minLines="5"

android:scrollHorizontally="false"

android:scrollbars="vertical" />

#2楼

所有这些都很好,但是如果您在上层滚动视图中有您的edittext,则无法工作:)也许最常见的例子是“设置”视图,它有很多项目,超出了可见区域。 在这种情况下,您将它们全部放入滚动视图以使设置可滚动。 如果您在设置中需要多行可滚动编辑文本,则其滚动将不起作用。

#3楼

试试这个,将这些行添加到编辑文本视图中,我将添加我的。 确保你理解它

android:overScrollMode="always"

android:scrollbarStyle="insideInset"

android:scrollbars="vertical"

android:inputType="textMultiLine"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:id="@+id/editText_newprom_description"

android:padding="10dp"

android:lines="5"

android:overScrollMode="always"

android:scrollbarStyle="insideInset"

android:minLines="5"

android:gravity="top|left"

android:scrollbars="vertical"

android:layout_marginBottom="20dp"/>

并在你的java类make点击listner到这个编辑文本如下,我将根据你的添加我的,chane名称。

EditText description;

description = (EditText)findViewById(R.id.editText_newprom_description);

description.setOnTouchListener(new View.OnTouchListener() {

@Override

public boolean onTouch(View view, MotionEvent motionEvent) {

view.getParent().requestDisallowInterceptTouchEvent(true);

switch (motionEvent.getAction() & MotionEvent.ACTION_MASK){

case MotionEvent.ACTION_UP:

view.getParent().requestDisallowInterceptTouchEvent(false);

break;

}

return false;

}

});

这对我来说很好

#4楼

android:scrollHorizontally="false"

如果它在xml中不起作用,那么以编程方式执行它会很奇怪。

listView.setHorizontallyScrolling(false);

#5楼

要禁用先前在主题使用xml属性中分配的行数: android:lines="@null"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值