//创建背景透明的对话框 AlertDialog.THEME_HOLO_LIGHTAlertDialog.Builder b = new AlertDialog.Builder(myContext.getApplicationContext(), AlertDialog.THEME_HOLO_LIGHT);dialog = b.create();  




网上还有一种,但是在android5.0以上,就不能让背景透明了,实际上他们只是让对话框的内容透明

//获取dialog的布局属性WindowManager.LayoutParams wmParams = dialog.getWindow().getAttributes();//wmParams.format = PixelFormat.TRANSPARENT;  内容全透明wmParams.format = PixelFormat.TRANSLUCENT;  内容半透明wmParams.alpha=0.1f;    调节透明度,1.0最大 
//dialog设置各种属性
dialog.getWindow().setAttributes(wmParams);




经实践检测,即使是new AlertDialog.Builder(myContext.getApplicationContext(), AlertDialog.THEME_HOLO_LIGHT);也不能使所有android设备透明,有些android盒子,就还是留有白色背景,解决方法

AlertDialog.Builder b = new AlertDialog.Builder(myContext.getApplicationContext(), R.style.NoBackGroundDialog);dialog = b.create();


styles.xml:


这里不管是Theme.Holo.Light.Dialog,还是继承其他parent,例如Theme.DeviceDefault.Dialog,都可以透明!!!


   


更多相关文章

  1. android 背景边框变圆角的几种方法
  2. android按行读取文件内容的几个方法
  3. android中实现背景图片颜色渐变方法
  4. android PopupWindow 阴影背景 、动画 、点击显示、隐藏
  5. Android TextView带背景图片和自定义边框
  6. android 阻塞 对话框 完全阻塞 停止主进程类似于window MessageB
  7. Android在配置文件中配置Button再不同情况下的的背景
  8. Android提高篇内容整理
  9. ListView 输入法框遮挡内容

随机推荐

  1. zoomable android textview
  2. android 屏保锁中屏掉按键和HOME键的方法
  3. Android 保存图片到图库
  4. Android TableLayout的使用
  5. Android UI 开发入门—线性布局
  6. android处理单击双击和滑动事件
  7. Android Studio 闪退卡死的问题
  8. android 加载图片并在上面画图
  9. SeekBar的使用
  10. Android事件处理(6)