您的位置:首页 > 移动开发 > Android开发

如何让标题栏文字居中、

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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android layout encoding xml