In the custom title bar above 4.0, the 4.0 custom title bar

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.