Android : Android -does not display scrollbars in SCALED view

on Sunday, March 8, 2015


I've written a custom view in android that can pan and zoom, and that displays its scrollbars... at least as long as it isn't zoomed in.


So the question isn't "how do I draw scrollbars in a view". I have that part working.


Note that I am using View.scrollTo and View.setScale for scrolling and zooming. Which, as far as I can tell, seems to be the way it's supposed to be done now, what with canvas.getMatrix being deprecated (and so far I have not managed to find the position of the viewport on a scaled canvas without getMatrix).


Now, View.setScale, while easy to use in general, seems to have the pecularity that it does indeed scale the whole view, resulting for example in a viewport that is smaller than the screen when scale is set <1 (annoying but avoidable). It does also seem to have the sideffect that the scrollbars are drawn outside the viewport when scale significantly > 1. This is a bit frustrating, and I'm wondering if there's any trick to still draw the scrollbars if the view is zoomed in. Other than scaling and translating the canvas, which would force me to use a deprecated function to calculate where any clicks have occured.


0 comments:

Post a Comment