第一步: 首先来看布局文件: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 按钮Button单击背景切换
  2. android中改变标题栏的背景色
  3. Android使用系统分享文件给微信,QQ指定的用户
  4. Android文件下载使用Http协议
  5. 关于listView设置背景引起StackOverflowError 的疑惑
  6. ReactNative 命令生成bundle文件
  7. Android 手机存储文件各种路径

随机推荐

  1. 还在用枚举?我早就抛弃了!(Android 注解详解
  2. Android2.1烧入mini2440
  3. Android Studio代码调试大全
  4. Android从0到完整项目(1)使用Android(安卓)
  5. iPhone和Android
  6. Ubuntu Linux下android源码下载方法
  7. 《Android 4 高级编程(第3版)》试读
  8. Android 局部刷新原理
  9. Android Tools
  10. android应用安全――签名机制