public class MyDialog extends Dialog
{
public MyDialog()
{
setupUI()
}
private void setupUI()
{
requestWindowFeature(Window.FEATURE_NO_TITLE);
Window window = getWindow();
WindowManager.LayoutParams wl = window.getAttributes();
wl.x = 0; //这两句设置了对话框的位置.
wl.y = 0;
wl.width = 150;
wl.height = 150;
wl.alpha = 0.5f; //这句设置了对话框的透明度
wl.dimAmount = 0.01f;
wl.gravity = Gravity.BOTTOM | Gravity.RIGHT;
wl.flags = wl.flags | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
wl.flags = wl.flags | WindowManager.LayoutParams.FLAG_DIM_BEHIND;
window.setAttributes(wl);
window.setBackgroundDrawableResource(R.drawable.back);
}
}
实现一个有焦点的非模态对话框
最新推荐文章于 2020-10-30 02:04:47 发布