简体   繁体   English

如何禁用EditText的垂直滚动?

[英]How to disable vertical scroll of EditText?

I create EditText programmatically. 我以编程方式创建EditText。

Following is my code: 以下是我的代码:

mEditText = new EditText(mMainActivity);
mEditText.setVisibility(View.INVISIBLE);
mEditText.setTextSize(8);
mEditText.setSingleLine();
mEditText.setMaxLines(1);
mEditText.setLines(1);
mEditText.setVerticalScrollBarEnabled(false);

What I set above seems completely useless...Please help me. 我上面提到的似乎完全无用......请帮助我。

You can try setMovementMethod() It will disable the EditText text scrolling. 您可以尝试setMovementMethod()它将禁用EditText文本滚动。 But you have to manage text size. 但你必须管理文字大小。

eText.setMovementMethod(null);

Hope it will help you... 希望它能帮到你......

直接转到XML并放置属性:

android:scrollbars="horizontal"

What input type do you want? 你想要什么输入类型?

editText.setInputType(InputType.TYPE_**);

if email/phone you do not even need the 如果你甚至不需要电子邮件/电话

editText.setLines(1);
editText.setMaxLines(1);

Also note your method 还要注意你的方法

editText.setSingleLine(false);

May be changing the values on your maxLines and Lines methods. 可能会更改maxLines和Lines方法的值。

Set below properties: 设置如下属性:

mEditText.setSingleLine(true);
mEditText.setHorizontallyScrolling(true);

It will work. 它会工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM