In the custom title bar above 4.0, the 4.0 custom title bar
Several codes to be set:
private void setCustomTitle() {requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);setContentView(R.layout.main);getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.customtitle);}
In addition, you need to reference a custom style:
<style name="CustomizedWindowTitleBackground"> <item name="android:background">#044BF6</item> </style> <style name="titlebarstyle" parent="android:Theme"> <item name="android:windowTitleSize">48dp</item> <item name="android:windowTitleBackgroundStyle">@style/CustomizedWindowTitleBackground</item> </style>
Android custom title bar
Appcompat_v7 is a compatibility package of Google. It is a support library that allows users of Version 2.1 and lower than version 4.0 to use the interfaces of Version 4.0. Therefore, if you are using Theme 4.0 or later, you can directly use Theme. Light
Post the error message when Theme. AppCompat. Light is used.
How does android set the title bar size?
The built-in title bars in Android apps vary greatly from version to version, but there are very few custom attributes for system title bars below 2.3 or above. There are two ways to create a beautiful custom title bar during Android Application Development,
First, use a third-party framework, such as SerlockActionbar.
Second, make a layout in the XML header as the title bar (in fact, it is a common view)
I am using the second method, which is more flexible.