DialogFragment 宽度自定充满屏的问题

以前遇到的问题,没有记录,再次遇到了,又尝试了半天才解决。

View inflate = LayoutInflater.from(getContext()).inflate(R.layout.dialog_confirm_copy_search, null);

通过这种方式加载的布局,

1,这个方式的最后一个参数,会将布局中的最外层的布局的layout宽高无效。

想要可以控制显示的宽度,解决方法如下:

1,新建一个内层总布局,设置layout_margin 亲测有效

2,新建inset的布局背景,给最外层的布局加上,insert如下:

<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
    android:insetLeft="10dp"
    android:insetRight="10dp">//内层边距
    <shape>
        <corners android:radius="10dp" />
        <solid android:color="#fff" />
    </shape>
</inset>

至此,解决了DialogFragment的展示边框宽度不确定的设置无效问题

更新bug: 

            正常使用AlertDialog 却在Api19上出现宽度设置失效的问题。对比图如下

DialogFragment 宽度自定充满屏的问题

                                           

具体原因有待深究,但是解放方法是,将导入的app包下的AlertDialog     ------->修改为v7兼容包下的AlertDialog解决