Diaglog橫向全屏

dialog想改變默認寬度,橫向全屏,要在show之後,修改Attributes,
其中
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
必不可少,不加此行,DecorView會有padding,橫向一直不能鋪滿屏幕

        Window window = getWindow();
        WindowManager.LayoutParams lp = window.getAttributes();
        lp.gravity = Gravity.CENTER;
        lp.width = WindowManager.LayoutParams.MATCH_PARENT;//寬高可設置具體大小
        getWindow().setAttributes(lp);
        // 此行必不可少
        getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章