1.设置窗口风格 :

①在Manifest中设置主题属性android:theme="@android:style/Theme.Dialog",或者 Theme.Holo.Dialog.

②在Activity的onCreate方法中设置,必须在setContentView之前调用setTheme(android.R.style.Theme_Holo_Dialog)

使用Theme.Holo.Dialog为Android 4.X风格,效果较佳;而Theme.Dialog风格是2.X风格,较为落伍.

2.设置布局属性:

在调整界面的过程中,会发现Dialog风格的Activity和AlertDialog界面效果相差较大,这主要是因为AlertDialog使用了特性的属性.

例如:

Button风格 : style="?android:attr/buttonBarButtonStyle"

Button外层Layout风格 : style="?android:attr/buttonBarStyle"

水平分割线 : android:background="?android:attr/dividerHorizontal"

内容字体字号 : android:textAppearance="?android:attr/textAppearanceMedium"

以下是样例:

  1. <?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2. android:layout_width="match_parent"
  3. android:layout_height="match_parent"
  4. android:gravity="center_horizontal"
  5. android:orientation="vertical" >
  6.  
  7. <TextView
  8. android:id="@+id/live_wallpaper_dialog_content"
  9. android:layout_width="wrap_content"
  10. android:layout_height="wrap_content"
  11. android:layout_marginBottom="5dp"
  12. android:layout_marginTop="5dp"
  13. android:gravity="center_vertical|center_horizontal"
  14. android:text="This is Content"
  15. android:textAppearance="?android:attr/textAppearanceMedium" />
  16.  
  17. <View
  18. android:layout_width="match_parent"
  19. android:layout_height="1dp"
  20. android:background="?android:attr/dividerHorizontal" />
  21.  
  22. <LinearLayout
  23. style="?android:attr/buttonBarStyle"
  24. android:layout_width="match_parent"
  25. android:layout_height="wrap_content"
  26. android:measureWithLargestChild="true" >
  27.  
  28. <Button
  29. android:id="@+id/live_wallpaper_dialog_cancel"
  30. style="?android:attr/buttonBarButtonStyle"
  31. android:layout_width="wrap_content"
  32. android:layout_height="wrap_content"
  33. android:layout_weight="1"
  34. android:text="cancel" />
  35.  
  36. <Button
  37. android:id="@+id/live_wallpaper_dialog_download"
  38. style="?android:attr/buttonBarButtonStyle"
  39. android:layout_width="wrap_content"
  40. android:layout_height="wrap_content"
  41. android:layout_weight="1"
  42. android:text="download" />
  43. </LinearLayout>
  44. </LinearLayout>

 

3.如何设置点击空白处不退出Activity :

AlertDialog​是设置setCanceledOnTouchOutside(false)来实现的.

而Activity是通过设置setFinishOnTouchOutside(false);来达到效果.

Android-Dialog风格Activity开发的更多相关文章

  1. Android四种Activity的加载模式(转)

    建议首先阅读下面两篇文章,这样才可以更好的理解Activity的加载模式: Android的进程,线程模型: http://www.cnblogs.com/ghj1976/archive/2011/0 ...

  2. Android四种Activity的加载模式

    建议首先阅读下面两篇文章,这样才可以更好的理解Activity的加载模式: Android的进程,线程模型 http://www.cnblogs.com/ghj1976/archive/2011/04 ...

  3. Android 如何利用Activity的Dialog风格完成弹出框设计

    在我们使用Dialog时,如果需要用到很多自己设计的控件,虽然可以让弹出框显示出我们需要的界面,但却无法找到地方完成控制代码的编写,如何解决这个问题呢,我们可以将Activity伪装成Dialog弹出 ...

  4. 【转载】Android Metro风格的Launcher开发系列第二篇

    前言: 各位小伙伴们请原谅我隔了这么久才开始写这一系列的第二篇博客,没办法忙新产品发布,好了废话不说了,先回顾一下:在我的上一篇博客Android Metro风格的Launcher开发系列第一篇写了如 ...

  5. Android Metro风格的Launcher开发系列第三篇

    前言: 各位小伙伴,又到了每周更新文章了时候了,本来是周日能发出来呢,这不是赶上清明节吗,女王大人发话了,清明节前两天半陪她玩,只留给我周一下午半天时间写博客,哪里有女王哪里就有压迫呀有木有!好了闲话 ...

  6. android dialog,popupwindow,toast窗口的添加机制

    Dialog 窗口添加机制 代码示例 首先举两个例子: 例子1 在Activity中 @OnClick(R.id.but) void onClick() { Log.d("LiaBin&qu ...

  7. Android 面试题--Activity

    1.什么是 Activity?Activity是Android组件中最基本也是最为常见用的四大组件(Activity,Service服务,Content Provider内容提供,BroadcastR ...

  8. Android系统Google Maps开发实例浅析

    Google Map(谷歌地图)是Google公司提供的电子地图服务.包括了三种视图:矢量地图.卫星图片.地形地图.对于Android系统来说,可以利用Google提供的地图服务来开发自己的一些应用. ...

  9. Android 编码风格规范,很赞哦

    1. 前言 这份文档参考了 Google Java 编程风格规范和 Google 官方 Android 编码风格规范.该文档仅供参考,只要形成一个统一的风格,见量知其意就可. 1.1 术语说明 在本文 ...

随机推荐

  1. 焦点改变事件OnFocusChangeListener

    效果图 1.MainActivity.java package com.example.app2; import android.support.v7.app.AppCompatActivity; i ...

  2. React Native学习之自定义Navigator

    Navigator还是最常用的组件, 所以自己封装了一个, 使用起来也比较简单, 如下: 首先导入组件 var MLNavigator = require('../Lib/MLNavigator'); ...

  3. Android闪闪发光字体效果

    原文: http://blog.csdn.net/xu_fu/article/details/24484019 import android.content.Context; import andro ...

  4. Flex State

    在Flex 程序中,引入了状态设计的概念.在一个程序中,按照功能的需求,将界面切分成相对独立的部分.运行过程中,随着用户交互,界面在各个部分之间切换.比如在购物车程序中,登录界面.选购商品界面.购物车 ...

  5. 腾讯云会话服务器node+nginx

    1.除了一个正常的服务器还需要一个会话服务器(websocket),利用node加socket.io来做 2.正常安装Nginx yum install nginx 3.Nginx的配置内容略微不同( ...

  6. Oracle Process Cloud流程云实践

    本篇适合对Oracle Unified BPM有一定基础的人参考,本篇也是参考Oracle A-team  John Featherly的文章进行的实践. 1.      流程创建 打开cloud.o ...

  7. Automatic Diagnostic Repository

    转载自 http://www.eygle.com/archives/2007/08/11g_auto_diag_repository.html#comments Oracle Database 11g ...

  8. Delphi 最小化程序到任务栏托盘 增加右键PopMenu

    在做中间层时,中间层往往不需要点击关闭时立刻关闭,而是最小化到托盘.故而特意隐藏关闭按钮功能. 1)隐藏退出功能 用PopMenu退出菜单代替 1.增加popMenu退出菜单,绑定到窗体 2.增加变量 ...

  9. poj 3468 A Simple Problem with Integers 线段树区间更新

    id=3468">点击打开链接题目链接 A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072 ...

  10. Android Volley框架的使用(四)图片的三级缓存策略(内存LruCache+磁盘DiskLruCache+网络Volley)

    在开发安卓应用中避免不了要使用到网络图片,获取网络图片很简单,但是需要付出一定的代价——流量.对于少数的图片而言问题不大,但如果手机应用中包含大量的图片,这势必会耗费用户的一定流量,如果我们不加以处理 ...