【问题标题】:Implementing Pan and Zoom实现平移和缩放
【发布时间】:2013-12-11 16:12:40
【问题描述】:

我在 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 单独拖动每个视图。是否可以将所有视图作为一个组添加平移和缩放?

【问题讨论】:

标签: java android zooming pan


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-08
    • 2013-12-12
    • 2016-03-10
    • 2014-09-30
    • 1970-01-01
    相关资源
    最近更新 更多