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/Android
1.设置透明度(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)


更多相关文章

  1. android 设置Button或者ImageButton的背景透明 半透明 透明
  2. Android(安卓)FactoryTest 流程
  3. android listview的一些设置
  4. Android(安卓)Material Design 控件常用的属性
  5. Android学习记录使用Gallery实现炫丽的拖动效果
  6. Android(安卓)EditText属性大全
  7. android中用Spannable在TextView中设置超链接、颜色、字体
  8. eclipse中Android布局的基本操作
  9. ToolBar介绍

随机推荐

  1. 又见Android开发环境搭建
  2. 天杀的android官方文档——mapview只显示
  3. android webvie使用技巧
  4. 使用handler更新UI
  5. 【转】Notification 详解
  6. 基于Android中获取资源的id和url方法总结
  7. 浅入浅出Android(016):分别使用WebView和Int
  8. Android(安卓)webview解决JS报错chromium
  9. ListView 添加长度样式不固定的分割线
  10. 【Android】Webview常见问题