如何从底部打开对话框,但它只显示在android的底部屏幕的一半之间

时间:2017-02-04 17:14:36

标签: android dialog

这是我从底部尝试对话的方法

   dialog = new Dialog(activity, android.R.style.Theme_Black_NoTitleBar_Fullscreen);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.coachingtip_discover);
        ImageView imageclose = (ImageView) dialog.findViewById(R.id.btn_close1);

        TextView textsmg = (TextView) dialog.findViewById(R.id.discover_inspire_text);

        TextView textsmg2 = (TextView) dialog.findViewById(R.id.add_photo_text2);

        TextView textsmg3 = (TextView) dialog.findViewById(R.id.add_photo_text1);

        dialog.show();

1 个答案:

答案 0 :(得分:0)

这是您在底部呈现Dialog的方式:

dialog = new Dialog(activity, android.R.style.Theme_Black_NoTitleBar_Fullscreen);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.coachingtip_discover);
Window window = dialog.getWindow();
WindowManager.LayoutParams wlp = window.getAttributes();

wlp.gravity = Gravity.BOTTOM;
wlp.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND;
window.setAttributes(wlp);