Implementing Pan and Zoom

大憨熊 提交于 2019-12-11 18:12:51

问题


I have relative layout in XML. On a button press I am adding Views ti it:

   LayoutInflater inflater =
   (LayoutInflater)this.getSystemService( Context.LAYOUT_INFLATER_SERVICE );
   View iv = inflater.inflate( R.layout.motor_block, null );
   //LinearLayout iv = (LinearLayout) findViewById(R.id.motor_block);
   RelativeLayout rl = (RelativeLayout) findViewById(R.id.layout);

   rl.addView(iv);

Then I am using OnTouch to drag each of the Views INDIVIDUALLY. Is it possible to add pan and zoom to ALL the views as a group?


回答1:


yes it is, you need to set onTouchListener on your main layout, add ScaleGestureDetector and inside of its onScale method you can manipulate your views whatever you want.



来源:https://stackoverflow.com/questions/20218422/implementing-pan-and-zoom

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