Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/216.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
AlertDailog支持x、y轴定位,但android中不支持对话框_Android_Android Alertdialog - Fatal编程技术网

AlertDailog支持x、y轴定位,但android中不支持对话框

AlertDailog支持x、y轴定位,但android中不支持对话框,android,android-alertdialog,Android,Android Alertdialog,我正在尝试设置对话框的位置。我使用的是自定义视图,所以我使用Dialog类来创建警报对话框。这里我的问题是,x,y位置不适用于对话框警报,但适用于警报对话框警报。我不知道为什么会这样。提前感谢 使用对话框类为警报对话框编码,并且此对话框不显示在给定位置 Dialog dialog = new Dialog(getActivity(), android.R.style.Theme_Translucent_NoTitleBar); WindowManager.Layo

我正在尝试设置对话框的位置。我使用的是自定义视图,所以我使用
Dialog
类来创建警报对话框。这里我的问题是,x,y位置不适用于
对话框
警报,但适用于
警报对话框
警报。我不知道为什么会这样。提前感谢

使用对话框类为警报对话框编码,并且此对话框不显示在给定位置

Dialog dialog = new Dialog(getActivity(),
            android.R.style.Theme_Translucent_NoTitleBar);
    WindowManager.LayoutParams wmlp = dialog.getWindow().getAttributes();
    Log.v("ShelfShareFragment", "X-Axis: "+mXAxis+" Y-Axis: "+mYAxis);
    wmlp.gravity = Gravity.TOP | Gravity.LEFT;
    dialog.getWindow().setWindowAnimations(R.anim.anim_fade_in);
    wmlp.x = mXAxis; // x position
    wmlp.y = mYAxis; // y position

    LayoutInflater inflater = (LayoutInflater) getActivity()
            .getLayoutInflater();
    final View dialogView = inflater.inflate(R.layout.dialog_shelf_share,
            null);

    dialog.setContentView(dialogView);
            dialog.show()
使用AlertDialogclass为警报对话框编码。这一个工作正常,但我需要使用
dialog
class创建我的对话框

AlertDialog.Builder builder=new AlertDialog.Builder(getActivity());
    LayoutInflater inflater = (LayoutInflater) getActivity()
            .getLayoutInflater();
    View dialogView = inflater.inflate(R.layout.dialog_shelf_share,
            null);
    builder.setTitle("Checking");
    builder.setView(dialogView);
    builder.setCancelable(true);
    AlertDialog dialog = builder.create();
    WindowManager.LayoutParams wmlp = dialog.getWindow().getAttributes();
    Log.v("ShelfShareFragment", "X-Axis: "+mXAxis+" Y-Axis: "+mYAxis);
    wmlp.gravity = Gravity.TOP | Gravity.LEFT;
    wmlp.x = mXAxis; // x position
    wmlp.y = mYAxis; // y position
    dialog.getWindow().setWindowAnimations(R.anim.anim_zoom_out);
    dialog.show();

我想你错过了密码

getWindow().setAttributes()
请查收