Android:自定义标题栏(titlebar)
2015-06-12 11:13
561 查看
现在很多的Android程序都在标题栏上都显示了一些按钮和标题,这里尝试做个实例
在onCreate中添加:
布局文件:
为避免冲突,修改:AndroidManifest.xml 在<activity>标签中定义有效
style
在onCreate中添加:
//自定义标题 requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.main); //设置标题为某个layout getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.titlebar);
布局文件:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <Button android:id="@+id/back" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="上一步" android:textSize="18sp" /> <TextView android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" android:text="标题" android:textSize="18sp" android:gravity="center" /> <Button android:id="@+id/back" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="下一步" android:textSize="18sp" /> </LinearLayout>
为避免冲突,修改:AndroidManifest.xml 在<activity>标签中定义有效
android:theme="@style/mystyle"
style
<style name="mystyle" parent="android:Theme"> <item name="android:windowTitleSize">50dp</item> </style>
相关文章推荐
- Android应用开发提高篇(3)-----传感器(Sensor)编程(转)
- Android压缩图片到100K以下并保持不失真的高效方法
- Android中ksoap实现SOAP远程调用,支持字符串、数值、日期类型参数
- Android开发
- Android的context浅析
- Android学习笔记之Logcat流
- Android中处理崩溃异常
- Android 环境配置
- Android初学习 - 以代码方式(非XML)创建一个布局
- Android Notification通知详解
- Android中通过intent启动另一个应用
- Android NDK开发(转)
- Android 如何监听返回键,弹出一个退出对话框
- Android下如何计算两经纬点之间距离
- android:windowSoftInputMode属性详解
- Android开发问题
- Android-做个性化的进度条
- 【转】Android出现“Read-only file system”解决办法
- Android开发中常用到的一些开源框架
- 在安装android studio时如何修改properties类型文件