如何定义对话片段的引力?
How to define gravity of a Dialog Fragment?
我希望我的对话框始终位于开头,但它始终位于中间。
我给你举个例子==>
代码如下-->点击图片-->出现对话框==>
Dialog dialog; //your dialog declaration
//
//
//
oncreate(){
imageView = (ImageView) findViewById(R.id.customProfileGridImg);
dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.activity);
Window window = dialog.getWindow();
WindowManager.LayoutParams wlp = window.getAttributes();
wlp.gravity = Gravity.START |Gravity.TOP; //change direction as per your requirement
wlp.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND;
window.setAttributes(wlp);
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog.show();
}
});
}
我希望我的对话框始终位于开头,但它始终位于中间。
我给你举个例子==>
代码如下-->点击图片-->出现对话框==>
Dialog dialog; //your dialog declaration
//
//
//
oncreate(){
imageView = (ImageView) findViewById(R.id.customProfileGridImg);
dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.activity);
Window window = dialog.getWindow();
WindowManager.LayoutParams wlp = window.getAttributes();
wlp.gravity = Gravity.START |Gravity.TOP; //change direction as per your requirement
wlp.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND;
window.setAttributes(wlp);
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog.show();
}
});
}