2016-01-28 36 views
0

如何應用在Android中放大,縮小,拖動和旋轉手勢對話框。我試過使用ScaleGestureDetector,但沒有運氣。在Android中的縮放對話框

我已經搜索了很多,但我只得到有關imageview和佈局的結果。

+0

創建一個自定義佈局打開它作爲一個dailog並應用在其上 – Abhishek

+0

與對話本身的任何其他選擇嗎? – BMM

回答

0

您可以使用活動來包裝對話框。並且您可以使用活動放大或縮小等。

的對話是這樣的:

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 

     } 
    }); 
} 

} 
+0

我必須使用對話框,因爲每一件事情都是完美的。只有縮放和所有的手勢是剩餘的。沒有太多時間來改變以前完成的一切。 – BMM

+0

你不需要做更多的事情來改變對話框的活動! – hongbochen

+0

但我的對話框不覆蓋整個屏幕,是否可以使用活動對話框? – BMM

0

您應該創建延伸的對話框類的類,然後你可以創建一個姿勢檢測並連接到類的onTouchEvent。

這裏是一個代碼示例,從這裏指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; 
    } 
} 

}