Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/193.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 相框宽度_Android_Dialogfragment - Fatal编程技术网

Android 相框宽度

Android 相框宽度,android,dialogfragment,Android,Dialogfragment,我正在使用dialogFragment创建自己的自定义片段,但其大小与priview中的不一样 这是预览中显示的内容 显示对话框时会发生这种情况 我希望它看起来和我的预览版一模一样-我该怎么办?试试这个 final Dialog dialog = new Dialog(mContext, R.style.Theme_Transparent); View view = LayoutInflater.from(mContext)

我正在使用dialogFragment创建自己的自定义片段,但其大小与priview中的不一样
这是预览中显示的内容

显示对话框时会发生这种情况

我希望它看起来和我的预览版一模一样-我该怎么办?

试试这个

    final Dialog dialog = new Dialog(mContext, R.style.Theme_Transparent);

    View view = LayoutInflater.from(mContext)
                           .inflate(R.layout.layout_custom_dialog, null);
    dialog.setContentView(view);

    Window window = dialog.getWindow();
    WindowManager.LayoutParams wlp = window.getAttributes();
    wlp.width = wlp.MATCH_PARENT;
    wlp.gravity = Gravity.TOP;
    wlp.flags &= ~WindowManager.LayoutParams.FLAG_BLUR_BEHIND;
    window.setAttributes(wlp);
并将其添加到
styles.xml
文件中

    <style name="Theme.Transparent" parent="android:Theme">
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowIsFloating">true</item>
        <item name="android:backgroundDimEnabled">true</item>
    </style>

真的
@android:彩色/透明
@空的
真的
真的
真的