activity theme parent 属性浅析

在AndroidManifest.xml文件中,能够对每个Activity设置android:theme

theme的设置 能够设置为系统自带的格式,也能够自定义格式。html

 

A: 系统自带格式android

   

一、android:theme="@android:style/Theme"windows

默认状态,即若是theme这里不填任何属性的时候,默认为Themeapp

二、android:theme="@android:style/Theme.NoDisplay"ui

任何都不显示。比较适用于只是运行了activity,但未显示任何东西xml

三、android:theme="@android:style/Theme.NoTitleBar“htm

背景主题的没有标题栏的样式,默认若是没有设置的话,显示黑背景继承

四、android:theme="@android:style/Theme.NoTitleBar.Fullscreen"ip

背景主题的没有标题栏且全屏的样式,默认为黑背景input

五、android:theme="@android:style/Theme.Black"

默认状态下黑背景

六、android:theme="@android:style/Theme.Black.NoTitleBar"

黑背景主题的没有标题栏的样式

七、android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"

黑背景主题的没有标题栏且全屏的样式

八、android:theme="@android:style/Theme.Light"

默认状态下亮背景,与上述黑背景Theme.Black相反

九、android:theme="@android:style/Theme.Light.NoTitleBar"

亮背景主题的没有标题栏的样式,与Theme.Black.NoTitleBar相反

十、android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen"

亮背景主题的没有标题栏且全屏显示的样式,与Theme.Black.NoTitleBa.Fullscreenr相反

十一、android:theme="@android:style/Theme.Dialog"

对话框样式 将整个activity变成对话框样式出现

十二、android:theme="@android:style/Theme.InputMethod"

Window animations that are applied to input method overlay windows

1三、android:theme="@android:style/Theme.Panel"

删除掉全部多余的窗口装饰,在一个空的矩形框中填充内容,做用范围至关于把dialog中的全部元素所有去掉,只是一个空的矩形框,且此为默认的样式

1四、android:theme="@android:style/Theme.Light.Panel"

删除掉全部多余的窗口装饰,在一个空的矩形框中填充内容,做用范围至关于把dialog中的全部元素所有去掉,只是一个空的矩形框,且默认是light的样式

1五、android:theme="@android:style/Theme.Wallpaper"

使用墙纸作主题,默认状态。

1六、android:theme="@android:style/Theme.WallpaperSettings"

使用墙纸作主题,默认是使用将上一个界面调暗以后做为主题

1七、android:theme="@android:style/Theme.Light.WallpaperSettings"

使用墙纸作主题,默认Light状态

1八、android:theme="@android:style/Theme.Wallpaper.NoTitleBar"

使用墙纸作主题,且没有标题栏

1九、android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen"

使用墙纸作主题,且没有标题栏,且全屏显示

20、android:theme="@android:style/Theme.Translucent"

半透明状态下的背景,将运行此activity以前的屏幕做为半透明状态做为此activity运行时的样式。

2一、android:theme="@android:style/Theme.Translucent.NoTitleBar"

半透明状态下没有标题栏的背景,将运行此activity以前的屏幕做为半透明状态做为此activity运行时的样式。

2二、android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"

半透明状态下没有标题栏且全屏的背景,将运行此activity以前的屏幕做为半透明状态做为此activity运行时的样式

能够在单个Activity里设置,也能够在applicaiton里全局设置。好比:

<activity android:screenOrientation="portrait" android:name=".ui.RegisterActivity" android:theme="@android:style/Theme.NoTitleBar"></activity>

 

 

B:也能够自定义

     在activity里加入 android:theme="@style/MyTitleBar" 再在 style.xml里加入

   <style name="MyTitleBar" parent="android:Theme">
        <item name="android:windowTitleSize">50dip</item>

         <item name="android:windowTitleBackgroundStyle">@style/MyTitleBackground</item>
        <item name="android:windowTitleStyle">@style/WindowTitle</item>
  </style>

 <!-- 自定义标题栏背景图 -->
  <style name="MyTitleBackground" parent="android:TextAppearance.WindowTitle">
   <item name="android:background">@drawable/bg_topbar</item>
  </style>
  <style name="WindowTitle" parent="android:TextAppearance.WindowTitle">
   <item name="android:singleLine">true</item>

  </style>

这里的parent是继承于android:Theme,因此在下面的样式里,只能是window开头的样式才起做用,全部样式请参考\sdk\docs\reference\android\R.attr.html,

也能够设置windowTitleBackgroundStyle 为@style/MyTitleBackground,这样就能够在MyTitleBackground里,设置背景图啦,

相关文章
相关标签/搜索