实现平移和缩放

时间:2013-11-26 13:30:03

标签: java android zoom pan

我在XML中有相对布局。按下按钮我正在添加视图:

   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);

然后我使用OnTouch拖动每个视图INDIVIDUALLY。是否可以将平移和缩放作为一组添加到所有视图中?

1 个答案:

答案 0 :(得分:0)

是的,您需要在主布局上设置onTouchListener,添加ScaleGestureDetector,并且在其onScale方法中,您可以随意操纵视图。

相关问题