有几种方法可以这样做:
第一种方法:
FEATURE_CUSTOM_TITLE
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.foo_layout);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title_bar);
or
youractivity.setTitle();
笔记!TextView
您可以在布局中包含一个简单的内容custom_title_bar
让你custom_title_bar
布局如下:
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/titleTextView"
style="@android:style/WindowTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
/>
</LinearLayout>
第二种方法:
活动.setTitle
this.setTitle("My Title!");