1.配置xml
首先要在最外层定义一个RetiveLayout布局(布局任意),然后在定义一个布局用来显示内容。
2.DialogFragment
1.在onActivityCreated()给dialog设置宽高
Window window = getDialog().getWindow();
ViewGroup.LayoutParams attributes = window.getAttributes();
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT);
2.在onCreateView()设置样式
getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);//无标题
getDialog().setCanceledOnTouchOutside(true);//点击边际可消失
3.在style文件配置.ActionSheetDialogStyle
<style name="ActionSheetDialogStyle"parent="@android:style/Theme.Dialog">
<item name="android:windowBackground">@android:color/transparent
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowIsFloating">true</item> <!-- 边框 -->
<item name="android:windowFrame">@null</item>
<item name="android:backgroundDimEnabled">true</item> <!-- 无标题 -->
<item name="android:windowNoTitle">true</item> <!-- 半透明 -->
<item name="android:windowIsTranslucent">true</item>
3.调用
ChooseRoleDialog dialog = new ChooseRoleDialog();
dialog.setStyle(DialogFragment.STYLE_NORMAL,R.style.ActionSheetDialogStyle);
dialog.show(getSupportFragmentManager(),"");
网友评论