android Fragment添加Theme,使背景模糊
来源:互联网 发布:电脑软件乱码 编辑:程序博客网 时间:2024/04/29 17:11
Fragment添加Theme,为了达到点击按钮,切换到fragment,使背景模糊,我们可以在style.xml增加一个style,如下:
<!--qiulinhe:2015年8月7日11:19:22: 保证金背景风格 --> <style name="margintran" > <!-- 设置允许窗口半透明 --> <item name="android:windowIsTranslucent">true</item> <!-- 引用Android系统的动画半透明样式 --> <item name="android:windowAnimationStyle">@android:style/Animation.Translucent</item> <!-- 设定窗口背景颜色 --> <item name="android:windowBackground">@color/yellow</item> <!-- 隐藏窗口标题栏 --> <item name="android:windowNoTitle">true</item> <!-- 设定文字前景色 --> <item name="android:colorForeground">#fff</item> </style>
之后要用到该风格的话,可以使用下列代码:
//使用ContextThemeWrapper通过目标Theme生成一个新的Context Context ctxWithTheme = new ContextThemeWrapper( getActivity().getApplicationContext(), R.style.Theme_PageIndicatorDefaults); //通过生成的Context创建一个LayoutInflater LayoutInflater localLayoutInflater = inflater.cloneInContext(ctxWithTheme); //使用生成的LayoutInflater创建View ViewGroup rootView = (ViewGroup)localLayoutInflater.inflate( R.layout.fragment_programs_center, null, false); 得到的rootView就是所需要的View了,这段代码放在onCreateView中就可以了。
Android设置Dialog透明度、黑暗度方法
(2013-03-18 11:10:50)转载▼
标签:
android
设置dialog
透明度
黑暗度
模糊度
分类: java/vb/Android1.设置透明度(Dialog自身的透明度)
WindowManager.LayoutParams lp=dialog.getWindow().getAttributes();
lp.alpha=1.0f;
dialog.getWindow().setAttributes(lp);
alpha在0.0f到1.0f之间。1.0完全不透明,0.0f完全透明
2.设置黑暗度(Dialog自身的黑暗度)
dialog.setContentView(R.layout.dialog);
WindowManager.LayoutParams lp=dialog.getWindow().getAttributes();
lp.dimAmount=1.0f;
dialog.getWindow().setAttributes(lp);
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
dimAmount在0.0f和1.0f之间,0.0f完全不暗,1.0f全暗
3.设置Dialog底背景模糊和黑暗度
WindowManager.LayoutParams.FLAG_BLUR_BEHIND(设置模糊)
WindowManager.LayoutParams.FLAG_DIM_BEHIND(设置暗淡)
4.清除Dialog底背景模糊和黑暗度
getDialog().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND | WindowManager.LayoutParams.FLAG_DIM_BEHIND)
WindowManager.LayoutParams lp=dialog.getWindow().getAttributes();
lp.alpha=1.0f;
dialog.getWindow().setAttributes(lp);
alpha在0.0f到1.0f之间。1.0完全不透明,0.0f完全透明
2.设置黑暗度(Dialog自身的黑暗度)
dialog.setContentView(R.layout.dialog);
WindowManager.LayoutParams lp=dialog.getWindow().getAttributes();
lp.dimAmount=1.0f;
dialog.getWindow().setAttributes(lp);
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
dimAmount在0.0f和1.0f之间,0.0f完全不暗,1.0f全暗
3.设置Dialog底背景模糊和黑暗度
WindowManager.LayoutParams.FLAG_BLUR_BEHIND(设置模糊)
WindowManager.LayoutParams.FLAG_DIM_BEHIND(设置暗淡)
4.清除Dialog底背景模糊和黑暗度
getDialog().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND | WindowManager.LayoutParams.FLAG_DIM_BEHIND)
0 0
- android Fragment添加Theme,使背景模糊
- Fragment添加Theme
- 给 Fragment添加Theme
- 视频播放添加模糊背景
- Android 背景模糊专题
- Android 背景模糊
- android背景模糊化处理
- Android获取Theme的背景颜色
- android:theme决定AlertDialog的背景颜色
- Android获取Theme的背景颜色
- Android apply theme to a fragment
- android 添加背景方框
- Android 添加Fragment到回退栈
- Android 动态添加Fragment
- Android 动态添加Fragment
- Android 动态添加Fragment
- 去掉android关机背景模糊特效
- android实现图片模糊背景效果
- 天生我才必有用,关键你知道你适合做什么!
- iOS 第六课 自己常用方法集合写法
- Nginx版本的“helloworld”
- Dinic邻接矩阵版本
- listview复用 数据重复 id错乱问题已解决
- android Fragment添加Theme,使背景模糊
- discuz二次开发-门户下面diy模块(全能调取数据)
- js代码,qq空间秒赞,2015/8/7号实测
- 由家里网络故障谈起
- MySql获取各种日期
- 北大POJ_1079_Ratio
- hibernate缓存机制原理
- Vagrant is attempting to interface with the UI in a way that requires a TTY
- RAND函数和SRAND函数