[转]Api demo源码进修(3)App/Activity/Custom Title 自定义题目栏

本文转自:http://www.cosdiv.com/page/M0/S655/655478.html

Api demo源码进修(3)--App/Activity/Custom Title --自定义题目栏

应用法度的题目栏上的文字也可以经由过程Activity进步履态设备。在Activity中添加如下语句:

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

setContentView(R.layout.custom_title);

getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title_1);

此中R.layout.custom_title   设备的是主界面的布局, 
R.layout.custom_title_1  设备的是题目栏的布局。
在Activity中获取R.layout.custom_title_1   中的TextView,
然后就可以遵守本身的意愿批改其文字内容、对齐体式格式、字体色彩等内容了。
具体代码斗劲简单,api demo是经由过程两个EditText批改题目栏靠左和靠右的文字。


custom_title_1.xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/screen"
    android:layout_width="match_parent" android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView android:id="@+id/left_text"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentLeft="true"
        android:text="@string/custom_title_left" />

    <TextView android:id="@+id/right_text"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentRight="true"
        android:text="@string/custom_title_right" />

</RelativeLayout>


以上即可。英雄——就是这样一个人,他在决定性关头做了为人类社会的利益所需要做的事。——伏契克

原文地址:https://www.cnblogs.com/freeliver54/p/2601964.html