android自定义标题栏。。。。。。。
来源:互联网 发布:淘宝店铺属性怎么改 编辑:程序博客网 时间:2024/06/03 23:00
这尼玛真是蛋疼啊,弄了我一天啊这小小的标题栏
第一步在android工程目录下新建一个title.xml文件用于新建标题栏主题
<?xml version="1.0" encoding="utf-8"?><resources xmlns:android="http://schemas.android.com/apk/res/android"> <style name="CustomizedWindowTitleBackground"> <!--修改标题栏背景颜色 --> <item name="android:background">#047BF0</item> </style> <!-- parent只能用android:Theme默认主题,使用其他会出错--> <style name="titleBar" parent="android:Theme"> <item name="android:windowTitleSize">48dp</item> <item name="android:windowTitleBackgroundStyle">@style/CustomizedWindowTitleBackground</item> <!-- All customizations that are NOT specific to a particular API-level can go here. --> </style></resources>
这尼玛坑爹啊 parent="android:Theme"只能用这个默认的主题啊!!!!!! 尼玛改了其他主题报错啊!!!!!!!
you cannot combine custom titles with other会报这个错
第二步在layout文件下新建一个titleBar的布局文件,这是标题栏的布局文件
<span style="font-size:12px;background-color: rgb(255, 255, 255);"><?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"> <Button android:id="@+id/backButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="返回" /> <Spinner android:id="@+id/weekSpinner" android:layout_width="wrap_content" android:layout_height="wrap_content"> </Spinner></LinearLayout></span>
第三部
package com.example.administrator.myapplication;import android.app.Activity;import android.os.Bundle;import android.view.Window;public class ScheduleActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.activity_class__schedule); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.titlebar); }}</span>
在你要使用标题栏的Activity中添加这两句
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.titlebar);
super.onCreate(savedInstanceState); setContentView(R.layout.activity_class__schedule);
这两句之前调用,
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.titlebar);
在setContentView之后调用就行
最后在manifests文件中
在你想要调用这个标题栏的Activity中添加
android:theme="@style/titleBar"这么一行就行了
0 0
- android自定义标题栏progressBar
- Android自定义标题栏
- 自定义android标题栏
- android实现自定义标题栏
- Android自定义标题栏
- Android 自定义标题栏
- Android 自定义标题栏
- Android自定义标题栏
- Android自定义标题栏
- android之自定义标题栏
- Android自定义标题栏
- Android 自定义标题栏运用
- Android 自定义标题栏
- android ListView+自定义标题栏
- Android 自定义标题栏
- Android:自定义标题栏
- Android Actionbar自定义标题栏
- 自定义Android标题栏TitleBar
- 第九章--成本管理
- Linux文件管理、查找与光盘挂载
- iOS block 基本用法及代替代理
- DOS基本命令(基本部分)
- Android编程之LayoutInflater的inflate方法详解
- android自定义标题栏。。。。。。。
- 01==IOS(基本命令)
- c#创建窗体,向窗体添加控件,设置控件大小位置等属性,写控件的响应
- Hibernate实体关系
- Android-Activity之间显示和隐式跳转-Date 数据跳转-调用系统的的组件
- 括号匹配
- C++Huffman树的构造实现及编码译码过程
- 2015 6 3 --如何阅读一本书
- GDOI2016模拟8.18解密