去除DialogFragment的背景阴影,背景色,标题栏

style中:

<resources xmlns:android="http://schemas.android.com/apk/res/android">

    <style name="MyDialog" parent="@android:style/Theme.Dialog">        
        <item name="android:windowBackground">@android:color/transparent</item>        
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowTitleStyle">@null</item>
        <item name="android:colorBackgroundCacheHint">@null</item>
        <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
        <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
        <item name="android:gravity">center</item>
    </style>

</resources>

DialogFragment中:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setStyle(DialogFragment.STYLE_NO_TITLE, R.style.MyDialog);
}


@Override
public void onStart(){
	super.onStart();
	Window window = getDialog().getWindow();
	WindowManager.LayoutParams lp= window.getAttributes();
	lp.dimAmout = 0;
	lp.flags |= WindowManager.LayoutParams.FLAG_DIM_BEHIND;
	window.setAttributes(lp);
}

posted @ 2017-08-13 15:58  just_yang  阅读(9345)  评论(0编辑  收藏  举报