<LinearLayout xmlns: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"> <TextView android:text="@string/进击e小米出品" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout>
解释:tools:context="info.Activity.About "这一句不会被打包进APK,ADT的Layout Editor在当前的Layout文件里面设置对应的渲染上下文,说明当前的布局文件所在的渲染上下文是“info.Activity.About”对应的那个activity。java
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="info.dad.android" > <application <!--下面的activity设置了 name="info.Activity.About"的activity的theme--> <activity android:name="info.Activity.About" android:label="关于" android:theme="@android:style/Theme.Dialog" > </activity> </application> </manifest>
在manifest文件中设置了"info.Activity.About" 的theme,那么ADT的Layout Editor会根据这个Theme来渲染当前的Layout。android:theme="@android :style/Theme.Dialog" 将一个Activity显示为能话框模式。那么你在可视化布局管理器里面看到的背景、控件等风格就是Theme.Dialog的样子。仅用于给你看所见即所得的效果而已。android
总结:这种显示activity上下文布局的方式,不用写activity java 文件。app
01 android:theme="@android:style/Theme.Dialog" 将一个Activity显示为对话框模式 02 android:theme="@android:style/Theme.NoTitleBar" 无标题栏 03 android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 无标题栏,并全屏 04 android:theme="@android:style/Theme.Light" 白色背景 05 android:theme="@android:style/Theme.Light.NoTitleBar" 白色背景,无标题栏 06 android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen" 白色背景,无标题栏,全屏 07 android:theme="@android:style/Theme.Black" 黑色背景 08 android:theme="@android:style/Theme.Black.NoTitleBar" 黑色背景,无标题栏 09 android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" 黑色背景,无标题栏,全屏 10 android:theme="@android:style/Theme.Wallpaper" 用系统桌面为应用程序背景 11 android:theme="@android:style/Theme.Wallpaper.NoTitleBar" 用系统桌面为应用程序背景,无标题栏 12 android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen" 用系统桌面为应用程序背景,无标题栏,全屏 13 android:theme="@android:style/Translucent" 半透明 14 android:theme="@android:style/Theme.Translucent.NoTitleBar" 半透明,无标题栏 15 android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" 半透明,无标题栏,全屏 16 android:theme="@android:style/Theme.Panel" 17 android:theme="@android:style/Theme.Light.Panel"