自定义style,设置全屏属性

[html] view plain copy print ?
  1. <resources>
  2. <stylename="AppTheme"parent="android:Theme.Black"/>
  3. <stylename="processDialog">
  4. <itemname="android:windowIsFloating">true</item><!--是否浮现在activity之上-->
  5. <itemname="android:windowFullscreen">true</item>
  6. <itemname="android:windowIsTranslucent">false</item><!--半透明-->
  7. <itemname="android:windowNoTitle">true</item><!--无标题-->
  8. <itemname="android:windowBackground">@android:color/transparent</item><!--背景透明-->
  9. <itemname="android:backgroundDimEnabled">true</item><!--模糊-->
  10. <itemname="android:backgroundDimAmount">0.5</item>
  11. <itemname="android:alpha">0.3</item>
  12. </style>
  13. </resources>


代码中加载这个view并把view set到dialog上,这样全屏的dialog就完成了

[java] view plain copy print ?
  1. <spanstyle="white-space:pre"></span>mView=LayoutInflater.from(this).inflate(R.layout.process_dialog,null);
  2. processDialog=newDialog(LogActivity.this,R.style.processDialog);
  3. processDialog.setCancelable(false);
  4. processDialog.setContentView(mView);
  5. <spanstyle="white-space:pre"></span>mAutoCloseDialog=newAutoCloseDialog(processDialog);
  6. <spanstyle="white-space:pre"></span>mAutoCloseDialog.show(Prefs.DIALOG_DISPLAY_TIME);

接下来用一个封装好的类,做一个延时关闭的效果

[java] view plain copy print ?
  1. importjava.util.concurrent.Executors;
  2. importjava.util.concurrent.ScheduledExecutorService;
  3. importjava.util.concurrent.TimeUnit;
  4. importandroid.app.Dialog;
  5. publicclassAutoCloseDialog{
  6. privateDialogdialog;
  7. privateScheduledExecutorServiceexecutor=Executors.newSingleThreadScheduledExecutor();
  8. publicAutoCloseDialog(Dialogdialog){
  9. this.dialog=dialog;
  10. }
  11. publicvoidshow(longduration){
  12. Runnablerunner=newRunnable(){
  13. publicvoidrun(){
  14. dialog.dismiss();
  15. }
  16. };
  17. executor.schedule(runner,duration,TimeUnit.MILLISECONDS);
  18. dialog.show();
  19. }
  20. }

更多相关文章

  1. Android(安卓)属性动画中心点无限循环
  2. Android之View的视图测量过程
  3. Android(安卓)自定义文本框(带图片)
  4. android 状态栏与标题栏一体化
  5. ListView 滑动出现黑色边际问题
  6. RelativeLayoutd 的属性
  7. ADT-abundle-使用过程中不断出现的错误
  8. AndroidManifest.xml文件详解(supports-screens)
  9. 出错:PhoneFactory.getDefaultPhone must be called from Looper

随机推荐

  1. android Application Component研究之Bro
  2. android googleMap key 的申请
  3. Android Activity 悬浮式窗口实现
  4. Android官方培训课程中文版(v0.9.3)
  5. declare-styleable, 自定义属性
  6. unity Android(安卓)csv 数据持久化
  7. 修改Android(安卓)模拟器imei
  8. 最简单的基于FFmpeg的移动端例子附件:SDL
  9. Android Studio3.0 新特性 ~ New Features
  10. 如何使用Android Studio开发/调试Android