第一步: 首先来看布局文件:activty_about.xml

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context="info.Activity.About"><TextViewandroid:text="@string/进击e小米出品"android:layout_width="wrap_content"android:layout_height="wrap_content"/></LinearLayout>

解释:tools:context="info.Activity.About "这一句不会被打包进APK,ADT的LayoutEditor在当前的Layout文件里面设置对应的渲染上下文,说明当前的布局文件所在的渲染上下文是“info.Activity.About”对应的那个activity。

第二步:在AndroidManifest.xml中的设置activity的theme

<?xmlversion="1.0"encoding="utf-8"?><manifestxmlns:android="http://schemas.android.com/apk/res/android"package="info.dad.android"><application<!--下面的activity设置了name="info.Activity.About"的activity的theme--><activityandroid:name="info.Activity.About"android:label="关于"android:theme="@android:style/Theme.Dialog"></activity></application></manifest>

在manifest文件中设置了"info.Activity.About" 的theme,那么ADT的LayoutEditor会根据这个Theme来渲染当前的Layout。android:theme="@android :style/Theme.Dialog"将一个Activity显示为能话框模式。那么你在可视化布局管理器里面看到的背景、控件等风格就是Theme.Dialog的样子。仅用于给你看所见即所得的效果而已。

总结:这种显示activity上下文布局的方式,不用写activity java 文件。

附件:常用的系统提供的 android:theme 样式一览表

01android:theme="@android:style/Theme.Dialog"将一个Activity显示为对话框模式02android:theme="@android:style/Theme.NoTitleBar"无标题栏03android:theme="@android:style/Theme.NoTitleBar.Fullscreen"无标题栏,并全屏04android:theme="@android:style/Theme.Light"白色背景05android:theme="@android:style/Theme.Light.NoTitleBar"白色背景,无标题栏06android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen"白色背景,无标题栏,全屏07android:theme="@android:style/Theme.Black"黑色背景08android:theme="@android:style/Theme.Black.NoTitleBar"黑色背景,无标题栏09android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"黑色背景,无标题栏,全屏10android:theme="@android:style/Theme.Wallpaper"用系统桌面为应用程序背景11android:theme="@android:style/Theme.Wallpaper.NoTitleBar"用系统桌面为应用程序背景,无标题栏12android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen"用系统桌面为应用程序背景,无标题栏,全屏13android:theme="@android:style/Translucent"半透明14android:theme="@android:style/Theme.Translucent.NoTitleBar"半透明,无标题栏15android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"半透明,无标题栏,全屏16android:theme="@android:style/Theme.Panel"17android:theme="@android:style/Theme.Light.Panel"




更多相关文章

  1. android 用VideoView播放本地视频文件
  2. Android(安卓)读写文件的N种写法
  3. 进度条及拖动条背景颜色设置(progressDrawable)
  4. Android下各文件方法获取的路径
  5. 大话企业级android读书笔记(三)
  6. Android定制出厂默认输入法
  7. Android我自己的简易(秒表)计时器Chronometer
  8. android 按钮Button单击背景切换
  9. 【android】设置View字体点击变色和边框背景设置

随机推荐

  1. Android搜索附近的beacon
  2. Android(安卓)网络请求不能放在主线程上
  3. android 短信发送器
  4. Android的service学习(1)
  5. Android(安卓)API中文(42)—— ListView
  6. Android(安卓)Mvvm入门教程
  7. Android的四种基础动画
  8. Android腾讯微薄客户端开发十三:提及篇(与
  9. android opengl es 源码
  10. android微信摇一摇功能