`
test_angel
  • 浏览: 51648 次
  • 性别: Icon_minigender_2
  • 来自: 西安
社区版块
存档分类
最新评论

主题属性

 
阅读更多

常常需要对activity的主题进行设置,下面我就将一些常用的属性总结一下,方便自己以后使用!~~~

 

1.以下是一个常用的style:

 

<?xml version="1.0" encoding="utf-8"?>
<resources>
 <style name="CustomTheme">
 <item name="android:windowNoTitle">true</item>
 <item name="windowFrame">@drawable/screen_frame</item>
 <item name="windowBackground">@drawable/screen_background_white</item>
 <item name="panelForegroundColor">#FF000000</item>
 <item name="panelBackgroundColor">#FFFFFFFF</item>
 <item name="panelTextColor">?panelForegroundColor</item>
 <item name="panelTextSize">14</item>
 <item name="menuItemTextColor">?panelTextColor</item>
 <item name="menuItemTextSize">?panelTextSize</item>
 </style>
</resources>

 

 

注意:

      用了@符号和?符号来应用资源。

     @符号表明了我们应用的资源是前边定义过的(或者在前一个项目中或者在Android 框架中)。

     ?表明了我们引用的资源的值在当前的主题当中定义过。通过引用在<item>里边定义的名字可以做到(panelTextColor 用的颜色和panelForegroundColor中定义的一样 )。这中技巧只能用在XML资源当中。

例如:

<!-- Window attributes -->

        <item name="windowBackground">@android:drawable/screen_background_dark</item>
        <item name="windowFrame">@null</item>
        <item name="windowNoTitle">false</item>
        <item name="windowFullscreen">false</item>
        <item name="windowIsFloating">false</item>
        <item name="windowContentOverlay">@android:drawable/title_bar_shadow</item>
        <item name="windowTitleStyle">@android:style/WindowTitle</item>
        <item name="windowTitleSize">25dip</item>
        <item name="windowTitleBackgroundStyle">@android:style/WindowTitleBackground</item>
        <item name="android:windowAnimationStyle">@android:style/Animation.Activity</item>

 

2.在主题中我们还可以设置页面的动画,属性如下:

Animation定义:
<!-- Standard animations for a full-screen window or activity. -->
    <style name="Animation.Activity">
        <item name="activityOpenEnterAnimation">@anim/activity_open_enter</item>
        <item name="activityOpenExitAnimation">@anim/activity_open_exit</item>
        <item name="activityCloseEnterAnimation">@anim/activity_close_enter</item>
        <item name="activityCloseExitAnimation">@anim/activity_close_exit</item>


        <item name="taskOpenEnterAnimation">@anim/activity_open_enter</item>
        <item name="taskOpenExitAnimation">@anim/activity_open_exit</item>
        <item name="taskCloseEnterAnimation">@anim/activity_close_enter</item>
        <item name="taskCloseExitAnimation">@anim/activity_close_exit</item>
  
        <item name="taskToFrontEnterAnimation">@anim/activity_open_enter</item>
        <item name="taskToFrontExitAnimation">@anim/activity_open_exit</item>
        <item name="taskToBackEnterAnimation">@anim/activity_close_enter</item>
        <item name="taskToBackExitAnimation">@anim/activity_close_exit</item>
        
        <item name="wallpaperOpenEnterAnimation">@anim/wallpaper_open_enter</item>
        <item name="wallpaperOpenExitAnimation">@anim/wallpaper_open_exit</item>
        <item name="wallpaperCloseEnterAnimation">@anim/wallpaper_close_enter</item>
        <item name="wallpaperCloseExitAnimation">@anim/wallpaper_close_exit</item>


        <item name="wallpaperIntraOpenEnterAnimation">@anim/wallpaper_intra_open_enter</item>
        <item name="wallpaperIntraOpenExitAnimation">@anim/wallpaper_intra_open_exit</item>
        <item name="wallpaperIntraCloseEnterAnimation">@anim/wallpaper_intra_close_enter</item>
        <item name="wallpaperIntraCloseExitAnimation">@anim/wallpaper_intra_close_exit</item>


        <item name="fragmentOpenEnterAnimation">@animator/fragment_open_enter</item>
        <item name="fragmentOpenExitAnimation">@animator/fragment_open_exit</item>
        <item name="fragmentCloseEnterAnimation">@animator/fragment_close_enter</item>
        <item name="fragmentCloseExitAnimation">@animator/fragment_close_exit</item>
        <item name="fragmentFadeEnterAnimation">@animator/fragment_fade_enter</item>
        <item name="fragmentFadeExitAnimation">@animator/fragment_fade_exit</item>
    </style>

 

3.一些系统的主题:

    android:theme = "@android:style/Theme.Dialog"    将一个Activity显示为能话框模式  
    android:theme = "@android:style/Theme.NoTitleBar"   不显示应用程序标题栏  
    android:theme = "@android:style/Theme.NoTitleBar.Fullscreen"   不显示应用程序标题栏,并全屏  
    android:theme = "Theme.Light"   背景为白色  
    android:theme = "Theme.Light.NoTitleBar"   白色背景并无标题栏   
    android:theme = "Theme.Light.NoTitleBar.Fullscreen"   白色背景,无标题栏,全屏  
    android:theme = "Theme.Black"   背景黑色  
    android:theme = "Theme.Black.NoTitleBar"   黑色背景并无标题栏  
    android:theme = "Theme.Black.NoTitleBar.Fullscreen"     黑色背景,无标题栏,全屏  
    android:theme = "Theme.Wallpaper"   用系统桌面为应用程序背景  
    android:theme = "Theme.Wallpaper.NoTitleBar"   用系统桌面为应用程序背景,且无标题栏  
    android:theme = "Theme.Wallpaper.NoTitleBar.Fullscreen"   用系统桌面为应用程序背景,无标题栏,全屏  
    android:theme = "Translucent"   半透明  
    android:theme = "Theme.Translucent.NoTitleBar"  半透明、无标题栏  
    android:theme = "Theme.Translucent.NoTitleBar.Fullscreen"  半透明、无标题栏、全屏  
    android:theme = "Theme.Panel"   
    android:theme = "Theme.Light.Panel"  

     

     

     

     

     

     

     

     

     

     

    分享到:
    评论
    1 楼 liuy2012 2012-09-08  
    这个不错~~

    相关推荐

    Global site tag (gtag.js) - Google Analytics