美文网首页
自定义背景透明度的全屏dialog

自定义背景透明度的全屏dialog

作者: _蘇芳_ | 来源:发表于2017-08-30 14:59 被阅读25次

1、在styles.xml里加上

<style name="dialog_fullscreen" parent="@android:style/Theme.Translucent.NoTitleBar">
        <item name="android:windowTranslucentStatus">true</item>
        <!--自定义透明度-->
        <item name="android:windowBackground">@color/black_30</item>
    </style>

2、建一个DialogFragment

public class BaseDialogFragment extends DialogFragment {
    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setStyle(DialogFragment.STYLE_NO_TITLE, R.style.dialog_fullscreen);

    }

@Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    //自定义布局
       return  inflater.inflate(R.layout.dialog_share, null);
      }
}

相关文章

网友评论

      本文标题:自定义背景透明度的全屏dialog

      本文链接:https://www.haomeiwen.com/subject/ctbtjxtx.html