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

安卓Api Demo学习 App/Activity/Custom Title

2011-10-19 15:05 501 查看
首先要告诉系统自定义的类型

核心函数requestWindowFeature。一般用来自定义标题,以及标题栏进度图形,或者让程序没有title

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

setContentView(R.layout.custom_title);

getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title_1); <--这里设置Title的布局

Title的布局

<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="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentLeft="true"

android:text="@string/custom_title_left" />

<TextView android:id="@+id/right_text"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentRight="true"

android:text="@string/custom_title_right" />

</RelativeLayout>

final TextView leftText = (TextView) findViewById(R.id.left_text); 取得标题中的Textview组件

leftText.setText(leftTextEdit.getText()); 设置文字

效果如下

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: