android 修改窗体标题的字体式样和…
来源:互联网 发布:手机怎么修改淘宝名 编辑:程序博客网 时间:2024/05/06 02:50
自定义一个layout,然后通过requestWindowFeature和getWindow().setFeatureInt方法调用,
但是,我只是想改变标题栏字体的大小、颜色,并设置一个背景图片,并不想定义一个layout的xml文件。
那么,android有没有提供解决上述问题的方法呢,答案是肯定的,一定可以。
默认的标题栏式样太难看了,灰不啦吉的。
后来参考了一篇洋人博友的文章,最终有所收获。
http://zaman91.wordpress.com/2010/03/18/android-how-to-customize-default-themes-and-styles/
具体的操作步骤是:
1、在res/values添加styles.xml文件。
2、在res/values添加themes.xml文件。
3、styles.xml文件的代码
- <?xml
version="1.0" encoding="utf-8"?> - <resources
xmlns:adnroid="http://schemas.android.com/apk/res/android"> -
- <style
name="CustomWindowTitleBackgro und" parent="android:WindowTitleBackground"> -
<item name="android:background">@drawable/bg</item> - </style>
-
- <style
name="CustomWindowTitle" parent="android:WindowTitle"> -
<item name="android:textAppearance">@style/CustomWindowTitleText</item> - </style>
-
- <style
name="CustomWindowTitleText" parent="android:TextAppearance.WindowTitle"> -
<item name="android:textColor">#00f</item> -
<item name="android:textSize">14sp</item> -
<item name="android:textStyle">bold</item> - </style>
-
- </resources>
4、themes.xml文件的代码
- <?xml
version="1.0" encoding="utf-8"?> - <resources
xmlns:adnroid="http://schemas.android.com/apk/res/android"> -
- <style
name="titleTheme" parent="android:Theme" > -
<!-- <item name="android:windowTitleSize">30dp</item> --> -
<item name="android:windowTitleBackgroundSty le" >@style/CustomWindowTitleBackground </item> -
<item name="android:windowTitleStyle">@style/CustomWindowTitle</item> - </style>
-
- </resources>
5、修改工程的Manifest.xml文件
- <?xml
version="1.0" encoding="utf-8"?> - <manifest
xmlns:android="http://schemas.android.com/apk/res/android" -
package="com.android.customtitle" -
android:versionCode="1" -
android:versionName="1.0"> -
<application android:icon="@drawable/icon" android:label="@string/app_name"> -
<activity android:name=".CustomTitle" -
android:label="@string/app_name" -
android:theme="@style/titleTheme"> -
<intent-filter> -
<action android:name="android.intent.action.MAIN" /> -
<category android:name="android.intent.category.LAUNCHER" /> -
</intent-filter> -
</activity> -
-
</application> -
<uses-sdk android:minSdkVersion="9" /> -
- </manifest>
6、效果图
说明:
关于style和theme的详细,可以查看一下的参考资料。
http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/res/res/values/styles.xml
http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/res/res/values/themes.xml
- android 修改窗体标题的字体式样和…
- android 修改窗体标题的字体式样和…
- android 修改窗体标题的字体式样和背景图(自定义标题栏)
- Android Tablayout + viewpager 切换时修改tablayout title(标题)的字体颜色和字体大小
- c# GroupBox 只修改标题的字体和颜色
- Xamarin Android 中修改 TabbedPage 标题字体
- android:修改PagerTabStrip中的背景颜色,标题字体的样式、颜色和图标以及指示条的颜色
- android:修改PagerTabStrip中的背景颜色,标题字体的样式、颜色和图标以及指示条的颜色
- 实现360浏览器式样的窗体
- TBW类型窗体的列标题修改
- 如何修改程序标题, 菜单的字体
- 修改UINavigationItem标题字体
- 修改iOS导航栏标题的字体颜色和大小以及导航栏的背景图片
- 修改android studio菜单栏和代码的字体和大小
- Android中部分修改字体和全局修改字体的方法
- android 修改标题的样式
- Android动态修改 TabHost 标签的图标和标题
- Android修改ActionBar背景颜色和标题颜色的style
- bat脚本(四)
- Android系统搜索对话框(浮动搜索…
- Android内核介绍[转]
- Android ANR问题分析[转]
- Android tiled background[转]
- android 修改窗体标题的字体式样和…
- Android style[转]
- 隐藏IOS软件
- Android 键盘系统
- 自定义BaseAdapter[转]
- Android自适应屏幕分辨率
- Activity之间切换的动画
- 关于web切图你需要知道的几件事情
- 反编译Apk[转]