I want to dynamically set scrollbars
in an EditText
programmatically, but I don't find this api as setscrollbars. Could anyone tell me if this can be done programmatically?
android:scrollbars="vertical"
Is this possible? How can I achieve this programmatically?
I was looking for a method to do this programatically, too.
Seems from http://developer.android.com/reference/android/view/View.html#attr_android:scrollbars it's not possible, cause no related method is mentioned there.
The only method that sounds good by description is:
View.setVerticalScrollBarEnabled(boolean)
but in my case it didn't work. But that may depend on the layout and the way it is used.
I am thinking now about having two layouts: one with the attribute set to "none" and one set to "vertical". Then in code I could decide which to use.
final TypedArray typedArray = context.obtainStyledAttributes(null, new int[]{});
try {
Method method = View.class.getDeclaredMethod("initializeScrollbars" , TypedArray.class);
method.invoke(this, typedArray);
}catch (Exception e) {
}
typedArray.recycle();
setVerticalScrollBarEnabled(true);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With