Android ImageView Scaling and translating issue

后端 未结 3 588
一向
一向 2020-11-21 23:35

I’m developing an android application (API 19 4.4) and I encounter some issue with ImageViews. I have a SurfaceView, in which I dynamically add ImageViews which I want to re

3条回答
  •  悲&欢浪女
    2020-11-22 00:07

    I finally use this (spacing is used to calculated the distance between two fingers), I offset the imageview after scaling to keep it centered, works fine for now :

        float newDist = spacing(event);
                float scale = newDist / oldDist;
    
                int oldH =getLayoutParams().height;
                int oldW =getLayoutParams().width;
    
                int newH =(int) (getLayoutParams().height*scale);
                int newW =(int) (getLayoutParams().width*scale);
    
                if(newH

提交回复
热议问题