设置标题栏背景
1> 准备背景图片: background_pix.png
注:用背景图片比用颜色好处,可以让背景看起来有凹凸感.
2> drawable文件夹下放xml文件
bitmap_repeat.xml
3> 定义样式文件style.xml
- @drawable/bitmap_repeat
- @style/StatusBarBackground
4> 在manifest.xml中引用主题android:theme="@style/XTheme"
自定义标题栏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);
}



