手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >Android 自定义标题栏背景
Android 自定义标题栏背景
摘要:设置标题栏背景1>准备背景图片:background_pix.png注:用背景图片比用颜色好处,可以让背景看起来有凹凸感.2>drawabl...

设置标题栏背景

1> 准备背景图片: background_pix.png

Android 自定义标题栏背景1

注:用背景图片比用颜色好处,可以让背景看起来有凹凸感.

2> drawable文件夹下放xml文件

bitmap_repeat.xml

<"1.0" encoding="utf-8"?> <bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/title_pic" android:tileMode="repeat"> </bitmap>

3> 定义样式文件style.xml

<"1.0" encoding="utf-8"?> <resources> <> <style name="StatusBarBackground"> <item name="android:background">@drawable/bitmap_repeat </item> </style> <style name="XTheme" parent="android:Theme"> <> <item name="android:windowTitleBackgroundStyle">@style/StatusBarBackground </item> </style> <> </resources>

4> 在manifest.xml中引用主题android:theme="@style/XTheme"

<activity android:name=".activity.MainActivty" android:screenOrientation="portrait" android:configChanges="keyboardHidden|orientation" android:theme="@style/XTheme"> </activity>

自定义标题栏layout文件ct_title.xml

注: ct_title.xml文件中用如下方式设置标题栏背景会出下填充不满效果

android:background="@drawable/bitmap_repeat "

在activity中引用

@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.main); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.ct_title); }

Android 自定义标题栏背景2

【Android 自定义标题栏背景】相关文章:

Android实现自定义带文字和图片Button的方法

Android 文件操作方法

Android中的Button自定义点击效果实例代码

Android支持的媒体格式

android 浏览器之多窗口方案详解

Android NDK开发之:配置环境的详解

Android开发之线性布局

Android布局——Preference自定义layout的方法

Android 开发中怎么使用自定义字体

Android 自定义View的使用介绍

精品推荐
分类导航