I was trying to add some buttons to some specific positions on an image. I am making use of webview to display the image because it embeds zoom in/out function; I have tried AbsoluteLayout to put buttons on it but when I zoom in, the button moved..
What should I do then? How can I make the button stick to one position of an image no matter how I zoom in and out?
It seems impossible to get the desired effect if you use
WebView, since WebView’s scaling does not affect the child view added to it.If you are working on API 11+, you can use a
ViewGroupsuch asFrameLayoutto hold the image and the button, then callView.setScaleX(float sf)andView.setScaleY(float sf)onFrameLayoutto scale it, so that all of its child will be scaled too.I don’t have a good solution for API level before 11, since
Viewclass does not contain transform information before API 11, maybe you can just recursively adjust theLayoutParamsof all the Views to get the effect, I didn’t try it, though.