B. *_*ney 5 android dialog canvas view coordinates
我是Android开发的菜鸟,我试图弄清楚如何在视图中的特定坐标处显示NewQuickAction3D弹出对话框.我正在将弹出窗口与本教程集成.本质上,我想使用弹出对话框显示用户触摸的数据,而不是使用"infoview"在画布上绘画.目前,弹出窗口显示在我将其锚定到的视图的顶部和中心.如何让它显示特定的坐标?任何帮助是极大的赞赏.
我的代码
public void updateMsg(String t_info, float t_x, float t_y, int t_c){
infoView.updateInfo(t_info, t_x, t_y, t_c); //Infoview paints to on a specific coordinate
quickAction.show(infoView); //How do I use the t_x & t_y coordinates here instead of just anchoring infoview
Run Code Online (Sandbox Code Playgroud)
编辑
public void updateMsg(String t_info, float t_x, float t_y, int t_c){
infoView.updateInfo(t_info, t_x, t_y, t_c);
WindowManager.LayoutParams wmlp = quickAction.getWindow().getAttributes(); //Error here getting window attributes
wmlp.gravity = Gravity.TOP | Gravity.LEFT;
wmlp.x = 100; //x position
wmlp.y = 100; //y position
quickAction.show(infoView);
}
Run Code Online (Sandbox Code Playgroud)
Rag*_*dan 13
覆盖视图的onTouch()
AlertDialog对话框;
AlertDialog dialog;
@Override
public boolean onTouchEvent(MotionEvent event) {
float x = event.getX();
float y = event.getY();
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
showDialog(); // display dialog
break;
case MotionEvent.ACTION_MOVE:
if(dialog!=null)
dialog.dismiss();
// do something
break;
case MotionEvent.ACTION_UP:
// do somethig
break;
}
return true;
}
public void showDialog()
{
AlertDialog.Builder builder = new AlertDialog.Builder(FingerPaintActivity.this);
dialog = builder.create();
dialog.setTitle("my dialog");
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
WindowManager.LayoutParams wmlp = dialog.getWindow().getAttributes();
wmlp.gravity = Gravity.TOP | Gravity.LEFT;
wmlp.x = 100; //x position
wmlp.y = 100; //y position
dialog.show();
}
Run Code Online (Sandbox Code Playgroud)
即使绘制用户触摸屏幕,也会显示对话框.所以在移动中解除对话框.
| 归档时间: |
|
| 查看次数: |
14359 次 |
| 最近记录: |