DialogFragment style设置
来源:互联网 发布:java项目添加log日志 编辑:程序博客网 时间:2024/05/23 01:11
class MDialogFragment extends DialogFragment{ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //1 通过样式定义 setStyle(DialogFragment.STYLE_NORMAL,R.style.Mdialog); //2代码设置 无标题 无边框 //setStyle(DialogFragment.STYLE_NO_TITLE|DialogFragment.STYLE_NO_FRAME,0); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { //3 在此处设置 无标题 对话框背景色 //getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); // //对话框背景色 //getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.RED)); //getDialog().getWindow().setDimAmount(0.5f);//背景黑暗度 //不能在此处设置style // setStyle(DialogFragment.STYLE_NORMAL,R.style.Mdialog);//在此处设置主题样式不起作用 return inflater.inflate(R.layout.l_dialog_fragment,container,false); } @Override public void onStart() { getDialog().getWindow().getAttributes().width=getResources().getDisplayMetrics().widthPixels; getDialog().getWindow().setGravity(Gravity.BOTTOM);//对齐方式 super.onStart(); } }
1.通过样式文件定义DialogFragment 的样式
在onCreate 中设置:
setStyle(DialogFragment.STYLE_NORMAL,R.style.Mdialog);
注意只能在此处设置,在onCreateView中设置style ,不会起作用
style定义如下:
<style name="Mdialog" parent="android:Theme.Holo.Light.Dialog"> <item name="android:windowBackground"> @drawable/bg</item> <item name="android:windowFrame">@null</item> <item name="android:backgroundDimEnabled">true</item> <item name="android:windowIsTranslucent">true</item> <item name="android:windowNoTitle">true</item> <item name="android:windowFullscreen">true</item> <item name="android:windowContentOverlay">@null</item> </style> <drawable name="bg">#ff3058ff</drawable>
2.也可以直接在代码中设置 无标题 无边框,以及背景色
2.1onCreate中:
//2代码设置 无标题 无边框 //setStyle(DialogFragment.STYLE_NO_TITLE|DialogFragment.STYLE_NO_FRAME,0);
2.2或者在onCreateView中:
//3 在此处设置 无标题 对话框背景色 //getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); // //对话框背景色 原有边框会自动消失 //getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.RED)); //getDialog().getWindow().setDimAmount(0.5f);//背景黑暗度
0 0
- DialogFragment style设置
- DialogFragment style设置
- android DialogFragment 设置大小
- DialogFragment设置自定义动画
- DialogFragment设置不可取消
- DialogFragment 设置全屏方法
- DialogFragment宽度设置
- DialogFragment设置全屏方法
- 给DialogFragment设置样式
- v4.DialogFragment设置宽高
- DialogFragment设置Cancelable(false)不起作用
- dialogFragment设置背景 为透明
- DialogFragment
- dialogFragment
- DialogFragment
- DialogFragment
- DialogFragment
- DialogFragment
- MyConcurrService
- 不想使用默认的“配置文件的位置”,那么可以来配置
- 4Sum
- 用Java编写一个小程序:键盘输入圆的半径,求圆的面积
- android Edittext 隐藏系统弹出的键盘
- DialogFragment style设置
- blog-servlet.xml配置文件
- 手机通信基本原理
- UVA - 512 Spreadsheet Tracking
- C++中继承方式与访问标号
- Absolute C++ 2.10题目
- hdu 2602 Bone Collector
- 访问方法的url就是类上的加上方法上的
- struts2中<s:property value=""/>不显示问题之一