`

Custom Android Window Title

阅读更多

Custom Android Window Title

 

Changing the window title in an Activity or globally across your entire application seems simple enough, but there is very little cohesive documentation for making it happen. You need to define custom styles and apply those styles to a custom theme.

This is placed in an xml document in the “values” folder. In the demo it is called custom_styles.xml. The name is arbitrary.

<!-- Sets the text styles -->
<?xml version="1.0" encoding="utf-8"?>
<!-- Sets the text styles -->
<resources>
     <style name="CustomWindowTitleText" parent="android:TextAppearance.WindowTitle">
          <item name="android:textSize">20dip</item>
          <item name="android:textColor">#5599FF</item>
          <item name="android:textStyle">bold|italic</item>
     </style>
     <!-- Changes the background color of the title bar -->
     <style name="CustomWindowTitleBackground">
           <item name="android:background">#222222</item>
     </style>

     <!-- Set the theme for the window title -->
     <!-- NOTE: setting android:textAppearence to style defined above -->
     <style name="CustomWindowTitle" parent="android:WindowTitle">
          <item name="android:textAppearance">@style/CustomWindowTitleText</item>
          <item name="android:shadowDx">0</item>
          <item name="android:shadowDy">0</item>
          <item name="android:shadowRadius">5</item>
          <item name="android:shadowColor">#1155CC</item>
      </style>
      <!-- Override properties in the default theme -->
      <!-- NOTE: you must explicitly the windowTitleSize property, the title bar will not re-size automatically, text will be clipped -->
      <style name="CustomTheme" parent="android:Theme">
           <item name="android:windowTitleSize">40dip</item>
           <item name="android:windowTitleStyle">@style/CustomWindowTitle</item>
           <item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
      </style>
</resources>

Lastly, to make the change take affect you need to set the theme in the manifest file.

<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@style/CustomTheme">
from site:http://labs.makemachine.net/2010/03/custom-android-window-title/
分享到:
评论

相关推荐

    Android-CustomTitle自定义toolsbar编写自己想要的标题栏

    CustomTitle 自定义toolsbar,编写自己想要的标题栏

    customWindow.zip

    用css进行了美化,2套主题,中英切换, 里面用到了fontawesome字体图标,自己写了一个该图标的使用类,基于最新的4.70版本,有需要的可以自行取用,只需要把fontawesomeicons类和资源文件里的 fontawesome-webfont.tff复制...

    Building.Android.UIs.with.Custom.Views

    Move beyond default UI templates, create and customize amazing UIs with Android Custom View Enable smooth data flow and create futuristic UIs by creating flexible custom views Scale your apps with ...

    Android代码-android-customtabs

    Android CustomTabs Chrome CustomTabs for Android demystified. Simplifies development and provides higher level classes including fallback in case Chrome isn't available on device. Usage How to ...

    Android代码-custom_keyboard

    custom_keyboard android 自定义键盘

    Android代码-android-custom-lint-rules

    Custom Lint Rules The Android lint tool is a static code analysis tool that checks your Android project source files for potential bugs and optimization improvements for correctness, security, ...

    android-custom-vg.jar

    自定义ViewGroup实现各种效果的jar包,更好的绘制自定义View的实现效果。 http://blog.csdn.net/alovebtoc/article/details/9104569具体使用教程请参考博客。

    Building Android UIs with Custom Views epub

    Building Android UIs with Custom Views 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书

    Android代码-一个Android Custom Tabs的demo

    Tabby (Cat), is a simple sample application demoing the features of the new Chrome Custom Tabs support library for Android. Using this application you can demo: Coloring the toolbar Displaying the ...

    Android代码-Android-FloatWindow

    FloatWindow readme-中文 Android自定义悬浮窗 原理很简单,就是借用了WindowManager这个管理类...Android custom floating window The principle is very simple, is to borrow WindowManager this management class

    Building Android UIs with Custom Views_Code 源码

    Building Android UIs with Custom Views_Code 源码 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书

    Android代码-Custom shaped layout for Android 自定义形状布局

    Custom shaped layout for Android 自定义形状布局 Features Clip layout and its childview. 2 way to set shape. Also custom shape by implement ShapeModel. Dependency Add this in your build.gradle file ...

    Android 简化 自定义标题栏

    一般项目中的标题栏都大同小异,demo为自定义,Activity中提供方法调用就行。有兴趣就下载看下吧,或许帮忙不大

    Android应用源码之CustomMenu_Android.zip

    Android应用源码之CustomMenu_Android

    android-custom-vg2.6.0.jar.zip

    内容包含:android-custom-vg2.6.0.jar包,android-custom-vg.2.6.0.src.zip源码,和示例代码。。http://blog.csdn.net/alovebtoc/article/details/17244111详情请参考博客详细介绍及使用方法

    Building Android UI Custom Views [pdf]

    Building Android UI Custom Views [pdf] Building Android UI Custom Views [pdf] Building Android UI Custom Views [pdf] Building Android UI Custom Views [pdf] Building Android UI Custom Views [pdf] ...

    Android Custom Dialog Demo

    在Android开发中,我们经常会需要在android界面上弹出一些对话框,比如询问用户或者让用户选择。,但是只是给出了创建各种类型对话框的方法,并未给出如何获取用户在对话框中做出选择后的数据,即如何监听用户做出的...

    C# xamarin android自定义标题栏

    xamarin android自定义标题栏,希望能够帮助到大家。。

    Android-Custom-Components.pdf

    Android-Custom-Components.pdf

    android custom dialog src

    自定义实现Dialog、AlertDialog,建议先看博客:UI效果(2): 自定义Dialog,然后再决定是否下载。

Global site tag (gtag.js) - Google Analytics