There are two methods:
1. Hide the title of the system and make a title-like effect on the layout.
2. Request the system service to make the system title use our defined style.
Now let's talk about the second type. The Code is as follows:
1. Create a title. xml file in the layout file.
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" ><TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="custom title" android:id="@+id/tv" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_launcher" /></LinearLayout>
2. Code in the activity:
Public class CustomtitleActivity extends Activity {@ Override public void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); // request the system to use a custom title. The code must be written to boolean flag = requestWindowFeature (Window. FEATURE_CUSTOM_TITLE); setContentView (R. layout. main); if (flag) {getWindow (). setFeatureInt (Window. FEATURE_CUSTOM_TITLE, R. layout. title );}}}