Android笔记之修改标题栏
2013-08-22 12:10
288 查看
一、修改标题栏样式
1、在Activity添加,顺序不能变:
2、新建layout/title_bar.xml来定义标题栏的控件布局
3、为标题栏新建一个style:在value/style.xml添加,名为test
(1)<style name="CustomWindowTitleBackground"> 设置标题栏背景
(2)<item name="android:windowTitleSize">20dp</item>定义标题栏高度
4,AndroidManifest.xml相应Activity添加 android:theme="@style/test"
1、在Activity添加,顺序不能变:
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.activity_main); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar);
2、新建layout/title_bar.xml来定义标题栏的控件布局
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageButton android:id="@+id/imageButton1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#00000000" android:layout_centerVertical="true" android:layout_alignParentLeft="true" android:src="@drawable/back" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:text="标题栏" /> </RelativeLayout>
3、为标题栏新建一个style:在value/style.xml添加,名为test
<style name="CustomWindowTitleBackground"> <item name="android:background">#565656</item> </style> <style name="test" parent="android:Theme"> <item name="android:windowTitleSize">20dp</item> <item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item> </style>
(1)<style name="CustomWindowTitleBackground"> 设置标题栏背景
(2)<item name="android:windowTitleSize">20dp</item>定义标题栏高度
4,AndroidManifest.xml相应Activity添加 android:theme="@style/test"
相关文章推荐
- android 学习笔记1--修改来电铃声
- Android逆向实例笔记—在so里对游戏的修改
- 修改 Android 标题栏(Title Bar)
- android风格统一化修改上方标题栏颜色
- Android 笔记:修改状态栏颜色(自定义状态栏颜色以与APP作风保持一致)
- Android 修改TitleBar标题栏样式
- Android开发笔记之主题背景的修改(设置Theme.NoTitleBar后Activity背景变成黑色)
- Android开发之修改标题栏样式
- 自定义Android标题栏修改TitleBar的布局
- androidpn-server笔记及BUG修改
- Android笔记--Fragment获取父Activity的控件并修改内容demo
- android如何修改dex文件添加非法指令 9efa (学习笔记)
- android笔记之Eclipse ADT的 keystore证书规格及修改证书密码别名
- Android源码开发笔记 WWAN Carrier config的修改
- Android 两行代码实现修改状态栏与标题栏颜色相同
- Android小笔记之对话框形式修改日期
- Android笔记1——开发环境搭建及工程导入、源码api版本修改
- Android Title标题栏的修改(隐藏,菜单)
- androidpn-client笔记及BUG修改
- android笔记,android程序设置标题栏和信息栏