App->Activity->Custom Dialog 例子使用Activity 来实现自定义对话框

类CustomDialogActivity本身无任何特别之处。关键的一点是其在AndroidManifest.xml中的定义:

        <activity android:name=".app.CustomDialogActivity"
android:label="@string/activity_custom_dialog"
android:theme="@style/Theme.CustomDialog"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
</intent-filter>
</activity>

CustomDialogActivity使用了自定义的CustomDialog 风格(Theme)。

Android应用可以使用自定义的界面风格(Theme),Theme 为一组相关的Style定义,可以应用于某个Activity或是整个Application。使用Theme的一个好处是可以为整个应用定义统一的界面风格(统一的背景色,字体等)。

定义Theme 和定义Style一样, 必须定义在/res/values子目录下,根元素名为resources, Theme 和Style的区别在于Theme应用于Activity和Application而 Style应用于单个的View。 其定义方法是一致的。

Style 定义支持 Inheritance, 也就是在定义新风格时可以基于系统定义的风格或是之前定义的风格:

  如Theme.CustomDialog 定义就是基于Android的Dialog风格(parent)而只修改的WindowsBackground属性,使用了褐色背景。

    <!-- A theme for a custom dialog appearance.  Here we use an ugly
custom frame. -->
<style name="Theme.CustomDialog" parent="android:style/Theme.Dialog">
<item name="android:windowBackground">@drawable/filled_box</item>
</style>
背景使用了shape,filled_box.xml如下:
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#f0600000"/>
<stroke android:width="3dp" android:color="#ffff8080"/>
<corners android:radius="3dp" />
<padding android:left="10dp" android:top="10dp"
android:right="10dp" android:bottom="10dp" />
</shape>

最新文章

  1. 发布 Rafy 源码到 GitHub
  2. RabbitMQ学习总结 第七篇:RCP(远程过程调用协议)
  3. [读书笔记] CSS权威指南2: 结构和层叠
  4. Python基本数据类型之dict
  5. HDU 4741 Save Labman No.004(计算几何)
  6. verify.js使用验证插件使用
  7. 迭代器iterator(三):Listlterator遍历arraylist,并用逆序输出结果
  8. Networking with PHP
  9. ua实现类似 www.taobao.com 在手机上打开自动转变为 m.taobao.com 的域名转换
  10. ThinkPHP之中的图片上传操作
  11. 《Genesis-3D开源游戏引擎完整实例教程-2D射击游戏篇08:弹幕系统》本系列完结
  12. C# Read/Write another Process&#39; Memory ZZ
  13. 微信小程序实操-image height:auto问题,url地址报错,“不在以下合法域名列表中”问题等
  14. 前端开发之css篇
  15. linux c函数指针的应用
  16. sass 安装与使用
  17. JVM深度解析
  18. system.transfer.list深度解析
  19. C#中byte[] 与string相互转化问题
  20. 用mysql存储过程代替递归查询

热门文章

  1. CF431D Random Task 二分+数位dp
  2. PHPExcel类库的使用
  3. ssh 配置无密码登录
  4. ssh证书生成与配置
  5. A reader
  6. Linux 文件系统的目录结构
  7. linux虚拟机管理
  8. zookeeper崩溃修复
  9. ubuntu 启动 ssh 服务
  10. python 之django (一) Windows环境下Django 1.6.11开发环境搭建(简易版)