Canvas.scale() on Android. Redraw full screen

旧巷老猫 提交于 2019-12-23 01:52:12

问题


So I'm using the example on Android Developers to implement pinch to zoom on my Activity.

Im Scaling A Custom View which has a ScrollView(and other things) inside it.

When im scaling, only the actual displayed Screen gets resized - but i want the scaled down things to show more of their content, because they have more space to do so when scaled down. I want them to use all the full screen space.

My Custom Views ondraw method just looks like this:

public void draw(Canvas canvas) {

    canvas.scale(mScaleFactor, mScaleFactor);
    super.draw(canvas);
}

this is what it looks like right now

If anything is unclear, just leave a comment. Any Help is appreciated edit: i made my custom View another Background color and now i see that my View is still full screen just not the childs.


回答1:


Try forcing the size of the view that is being scaled with a LayoutParams.

This thread has more detail on how to do this.




回答2:


I am Assuming you are having other layouts apart from your ScrollView which are in Horizontal Orientation or Vertical. Try using weight option in the XML Attributes of ScrollView with a value of 1.0, it might solve your problem.



来源:https://stackoverflow.com/questions/12722300/canvas-scale-on-android-redraw-full-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!