Yonghui
Yonghui

Reputation: 222

How to disable vertical scroll of EditText?

I create EditText programmatically.

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.

Upvotes: 2

Views: 2714

Answers (3)

Mohanraj
Mohanraj

Reputation: 326

Set below properties:

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

It will work.

Upvotes: 1

Victor Mwenda
Victor Mwenda

Reputation: 1801

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.

Upvotes: 0

MurugananthamS
MurugananthamS

Reputation: 2405

You can try setMovementMethod() It will disable the EditText text scrolling. But you have to manage text size.

eText.setMovementMethod(null);

Hope it will help you...

Upvotes: 2

Related Questions