Question

I'm creating my own personalized ListView by extending the ListView itself. This particular ListView shouldn't have scrollbars.

  1. How can I disable the XML android:scrollbars attribute for my custom ListView?
  2. I can't find a way to disable them programmatically. What am I missing?

The answer from dzeikei's will disable the scrollbars programmatically and ignore any value from android:scrollbars but what I'm really asking on 1. is how to make android:scrollbars an invalid attribute for my custom component.

Était-ce utile?

La solution

Updated OK as Richardo found out, seems like my original answer is the reverse way since the scrollbar is displayed internally :)

The correct way will be to call super.setHorizontalScrollBarEnabled(false) and super.setVerticalScrollBarEnabled(false) in the constructor and override setHorizontalScrollBarEnabled() and setVerticalScrollBarEnabled() do nothing :D

Override isHorizontalScrollBarEnabled() and isVerticalScrollBarEnabled() in your subclass to return false.

you could also override setHorizontalScrollBarEnabled() and setVerticalScrollBarEnabled() for good measure.

Autres conseils

Try keeping @null for android:scrollbars. Am not sure. But, I usually use @null when i want to remove anything from XML attributes.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top