Android-Dialog风格Activity开发
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"
以下是样例:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical" > <TextView
android:id="@+id/live_wallpaper_dialog_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:gravity="center_vertical|center_horizontal"
android:text="This is Content"
android:textAppearance="?android:attr/textAppearanceMedium" /> <View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/dividerHorizontal" /> <LinearLayout
style="?android:attr/buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:measureWithLargestChild="true" > <Button
android:id="@+id/live_wallpaper_dialog_cancel"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="cancel" /> <Button
android:id="@+id/live_wallpaper_dialog_download"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="download" />
</LinearLayout>
</LinearLayout>


3.如何设置点击空白处不退出Activity :
AlertDialog是设置setCanceledOnTouchOutside(false)来实现的.
而Activity是通过设置setFinishOnTouchOutside(false);来达到效果.
Android-Dialog风格Activity开发的更多相关文章
- Android四种Activity的加载模式(转)
建议首先阅读下面两篇文章,这样才可以更好的理解Activity的加载模式: Android的进程,线程模型: http://www.cnblogs.com/ghj1976/archive/2011/0 ...
- Android四种Activity的加载模式
建议首先阅读下面两篇文章,这样才可以更好的理解Activity的加载模式: Android的进程,线程模型 http://www.cnblogs.com/ghj1976/archive/2011/04 ...
- Android 如何利用Activity的Dialog风格完成弹出框设计
在我们使用Dialog时,如果需要用到很多自己设计的控件,虽然可以让弹出框显示出我们需要的界面,但却无法找到地方完成控制代码的编写,如何解决这个问题呢,我们可以将Activity伪装成Dialog弹出 ...
- 【转载】Android Metro风格的Launcher开发系列第二篇
前言: 各位小伙伴们请原谅我隔了这么久才开始写这一系列的第二篇博客,没办法忙新产品发布,好了废话不说了,先回顾一下:在我的上一篇博客Android Metro风格的Launcher开发系列第一篇写了如 ...
- Android Metro风格的Launcher开发系列第三篇
前言: 各位小伙伴,又到了每周更新文章了时候了,本来是周日能发出来呢,这不是赶上清明节吗,女王大人发话了,清明节前两天半陪她玩,只留给我周一下午半天时间写博客,哪里有女王哪里就有压迫呀有木有!好了闲话 ...
- android dialog,popupwindow,toast窗口的添加机制
Dialog 窗口添加机制 代码示例 首先举两个例子: 例子1 在Activity中 @OnClick(R.id.but) void onClick() { Log.d("LiaBin&qu ...
- Android 面试题--Activity
1.什么是 Activity?Activity是Android组件中最基本也是最为常见用的四大组件(Activity,Service服务,Content Provider内容提供,BroadcastR ...
- Android系统Google Maps开发实例浅析
Google Map(谷歌地图)是Google公司提供的电子地图服务.包括了三种视图:矢量地图.卫星图片.地形地图.对于Android系统来说,可以利用Google提供的地图服务来开发自己的一些应用. ...
- Android 编码风格规范,很赞哦
1. 前言 这份文档参考了 Google Java 编程风格规范和 Google 官方 Android 编码风格规范.该文档仅供参考,只要形成一个统一的风格,见量知其意就可. 1.1 术语说明 在本文 ...
随机推荐
- Python easygui 和 xlrd的安装
一.python的安装 1.我们从python官方网站:http://www.python.org下载python的安装包 2.解压后点击安装,安装完成后,将安装目录配置到环境变量的path里. 3 ...
- AppCompatActivity与toolbar的结合
原文:http://www.51itong.net/android-activity-appcompatactivity-toolbar-15750.html 另外一个博客:Android 5.x T ...
- golangWEB框架gin学习之获取get参数
原文地址:http://www.niu12.com/article/40package main import ( "fmt" "github.com/gin-gonic ...
- linux/mac系统的软链接文件与硬链接文件
1.硬连接只能使用在文件上,不可以使用在文件夹上.至于文件前面的硬链接数字的含义如下: 如图标注区,为硬连接的数量,文件前的数字1表示没有硬链接.文件夹前面的数字至少是2,含义是这个文件夹是空文件夹, ...
- C语言中的联合体union所占内存方式
当多个数据需要共享内存或者多个数据每次只取其一时,可以利用联合体(union).在C Programming Language 一书中对于联合体是这么描述的: 1)联合体是一个结构: ...
- http://jingyan.baidu.com/article/dca1fa6fa07000f1a44052f6.html
http://jingyan.baidu.com/article/dca1fa6fa07000f1a44052f6.html
- Servlet执行时一般实现哪几个方法?
public void init(ServletConfig config) public ServletConfig getServletConfig() public String getServ ...
- 转: Linux与JVM的内存关系分析
Linux与JVM的内存关系分析 引言 在一些物理内存为8g的服务器上,主要运行一个Java服务,系统内存分配如下:Java服务的JVM堆大小设置为6g,一个监控进程占用大约600m,Linux自身使 ...
- Node.js meitulu图片批量下载爬虫1.02版
以前版本需要先查看网页源码,然后肉眼找到图片数量和子目录,虽说不费事,但多少有点不方便. 于是修改了一下,用cheerio自己去找找到图片数量和子目录,只要修改页面地址就行了.至此社会又前进了一步. ...
- iOS-国家代码选择功能github开源分享
三行代码集成国家区号选择功能 功能执行效果如图: 开源链接: https://github.com/qxuewei/XWCountryCode 用法: 1.导入XWCountryCode类 2.在须要 ...