Reputation: 11834
In iOS I can easily change the inset of the scrollbar in a UIScrollView by setting the scrollIndicatorInsets. Basically what happens is the UIScrollView size and content area stays the same, yet the scrollbar can be smaller, which is very nice when using some (semi-transparent) overlays over the top or bottom of the scrollview, since the scrollbar won't be hidden behind the overlays.
If it possible to achieve the same result in Android? Could I have a full-size scrollview, yet have a smaller sized scrollbar (e.g. scrollview begins at pixel 0 and ends at pixel 100, scrollbar begins at pixel 10 and ends at pixel 90? If possible, how do I achieve this?
Upvotes: 1
Views: 1588
Reputation: 3347
From what I have seen, there is no API provided by Google to do this. You may have to inherit from ScrollView and override some method to achieve this effect. Something like this, perhaps:
@Override
protected void onDrawVerticalScrollBar(Canvas canvas,
Drawable scrollBar,
int l, int t, int r, int b) {
scrollBar.setBounds(l, t + mVerticalScrollInset, r, b);
scrollBar.draw(canvas);
}
Here mVerticalScrollInset
is a private variable in your class. I have a similar problem. I'm setting this variable in code, to achieve different vertical scroll insets dynamically as required by my application.
Upvotes: 2