如何让标题栏文字居中、
2012-03-05 12:52
190 查看
以下三句代码放到oncreat中即可
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.title);
注意3句代码的顺序
主要思想是通过一个XML实现对titile栏的位置控制
title.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_gravity="center">
<TextView android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="textTitle" />
</LinearLayout>
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.title);
注意3句代码的顺序
主要思想是通过一个XML实现对titile栏的位置控制
title.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_gravity="center">
<TextView android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="textTitle" />
</LinearLayout>
相关文章推荐
- SolidWorks工程图标题栏如何居中文字
- 小技巧:用CSS如何实现单行图片与文字垂直居中
- 如何让输入文字如何动态居中
- DIV+CSS如何让文字垂直居中
- 小技巧:用CSS如何实现单行图片与文字垂直居中
- 如何设置图片于文字居中
- DIV+CSS如何让文字垂直居中
- td内有图片和文字,如何都垂直居中
- DIV+CSS如何让文字垂直居中?
- css如何让文本框中的输入的文字始终垂直居中
- DrawText如何使多行文字居中
- 如何让TextView中的文字居中显示?
- LaTeX技巧374:如何在指定列宽的表格里实现文字居中
- Android UI 如何让TextView中的文字居中显示
- DIV+CSS如何让文字垂直居中?
- DIV+CSS如何让文字垂直居中?
- 让标题栏文字居中
- 软件标题栏文字居右或居中的方法
- Android UI 如何让TextView中的文字居中显示
- DrawText如何使多行文字居中