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()
使用AlertDialog
class为警报对话框编码。这一个工作正常,但我需要使用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()
请查收