Rahul Gupta
Rahul Gupta

Reputation: 5295

How to add a scrollbar in a EditText dynamically/programmatically in Android?

I know how to adda scrollbar through the xml properties such that there is a bar in the right side of the edittext field once we write stuff in it by making setSingleline(false).

My question is :-

is there a way to do the same through the activity , that is, dynamically? for eg:-

Code is :-

public class abc extends Activity
{

EditText edit = (EditText)findViewById(R.id.EditText1);

edit.setVerticalScrollBarEnabled(true);

edit.isVerticalScrollBarEnabled();
}

These two does not work. When i add these , i still am not able to see the scrollbar on the rightside of the Edittext when i scroll..

Through XML, when we add :- android:scrollbars="vertical" , then we are able to see the scrollbar..

I am asking for a WORKING way to do it through the activity dynamically or in other words programatically

Please its urgent. I would sincerely be thankful.

Upvotes: 2

Views: 1314

Answers (1)

Boris Mocialov
Boris Mocialov

Reputation: 3489

In XML

 android:fadeScrollbars="false"   

Dynamically/programatically:

edit.setScrollbarFadingEnabled(false); 

Upvotes: 2

Related Questions