0

How does one apply zoom in, zoom out, drag and rotate gestures on Dialog in Android. I have tried using ScaleGestureDetector but without luck.

I have searched a lot but I am only getting results related to imageview and layouts.

halfer
  • 19,824
  • 17
  • 99
  • 186
BMM
  • 161
  • 1
  • 1
  • 12

2 Answers2

0

You can use the activity to wrap a dialog.And you can use the activity zoom in or zoom out and so on.

The dialog is like this:

public class MessageBackDialog extends Activity {

// 提交按钮
private Button commitBtn;

// commentID
private String commentID;

// 当前的类型
private String type;

// appID
private String appID;

// 测试加载对话框
private LoadingDialog ld;

private DownLoadEventNotifier den;

// 编辑评论
private EditText et_text_reply;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);

    setContentView(R.layout.dialog_reply_layout);

    Intent intent = getIntent();
    type = intent.getStringExtra("TYPE");

    if (type.equals("BACK")) {
        commentID = intent.getStringExtra("CID");
    } else {
        appID = intent.getStringExtra("AID");
    }

    initView();
    setListener();
}

private void initView() {
    ld = LoadingDialog.createDialog(getApplicationContext());

    et_text_reply = (EditText) findViewById(R.id.et_text_reply);
    commitBtn = (Button) findViewById(R.id.btn_commit);

    den = new DownLoadEventNotifier(new DownInterface() {

        @Override
        public void onDownloadSuccess(String result) {
            // TODO Auto-generated method stub

        }
    });

}

private void setListener() {
    commitBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

        }
    });
}

}
hongbochen
  • 123
  • 6
0

You should create a class which extends the dialog class and then you can create a gesture detector and attach to the ontouchevent of the class.

Here is a code example, taken from refer here this post:

public class GestureDialog extends Dialog {
  public GestureDialog (Context context, int theme) {
      super(context, theme);

      gestDetec = new MyGestureDetector();    //inital setup
        gestureDetector = new GestureDetector(gestDetec); 
        gestureListener = new View.OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
                if (gestureDetector.onTouchEvent(event)) {
                    return true;
                }
                return false;
            }
        };
  }
  @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (gestureDetector.onTouchEvent(event))
          return true;
      else
          return false;
    }
class MyGestureDetector extends SimpleOnGestureListener {
  @Override
  public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {

      System.out.println( "Help im being touched!" );
      return false;
  }
}

}
Community
  • 1
  • 1
Abhishek
  • 1,654
  • 2
  • 18
  • 31