Android中的缩放对话框
如何在Android中的对话框上应用放大、缩小、拖动和旋转手势。我试过使用Android中的缩放对话框,android,dialog,rotation,zooming,drag,Android,Dialog,Rotation,Zooming,Drag,如何在Android中的对话框上应用放大、缩小、拖动和旋转手势。我试过使用scalegestruedetector,但运气不好 我搜索了很多,但只得到与imageview和layouts相关的结果。您可以使用“活动”包装对话框。您还可以使用“活动”放大或缩小等等 对话框如下所示: public class MessageBackDialog extends Activity { // 提交按钮 private Button commitBtn; // commentID private St
scalegestruedetector
,但运气不好
我搜索了很多,但只得到与imageview和layouts相关的结果。您可以使用“活动”包装对话框。您还可以使用“活动”放大或缩小等等 对话框如下所示:
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
}
});
}
}
您应该创建一个扩展dialog类的类,然后您可以创建一个手势检测器并附加到该类的ontouchevent 下面是一个代码示例,取自“请参阅此处”:
创建一个自定义布局,将其作为dailog打开,并将其应用于其他任何对话框选项?我只需要使用Dialog,因为在该对话框中所有操作都完成得非常完美。只剩下缩放和所有手势。没有太多的时间来更改以前所做的一切。您不需要做更多的事情来将对话框更改为活动!但是我的对话框没有覆盖整个屏幕,是否可以使用活动对话框?是的,此活动也没有覆盖整个屏幕。您可以给我您的电子邮件,我将演示发布给您,请稍候!
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;
}
}
}