Android Custom title bar

Source: Internet
Author: User

Android, at the beginning of the custom title bar encountered some problems, because many do not understand, spent a lot of time to solve.

Okay, nonsense. No, just the question:

Styles.xml

<name= "Apptheme"  parent= "Android:Theme.Holo"> < style >

The topics in the above-mentioned files are used in my androidmanifest.xml:

< Application         Android:allowbackup = "true"         android:icon= "@mipmap/ic_launcher"        android:label= "@string/app_name"          android:theme= "@style/apptheme"> ... < Application >

When the program finishes writing, the runtime throws such an exception:

Java.lang.RuntimeException:Unable to start activity componentinfo{com.czj.webo/com.czj.webo.mainactivity}:

Android.util.AndroidRuntimeException:You cannot combine custom titles with other title features (You can't combine custom headings with other title features) and it probably means that there are two or more title bars that are causing the conflict.

The code above is posted because this is the cause of the program crash. Through various search data, found that the cause of the error is the use of the theme "Android:theme." holo", change it to

"Android:Theme.Light" would be OK. But don't think it's going to solve the problem, and the new question is coming.

Custom title bar Some of the default property values are not what we want, so we need to set some basic properties on the custom title bar, by Styles.xml

    <stylename= "Customwindowtitlebackground">        <Itemname= "Android:background">#FFFAFA</Item>    </style>    <stylename= "Test"Parent= "Android:Theme.Light">        <Itemname= "Android:windowtitlesize">55dp</Item>        <Itemname= "Android:background">#FFFAFA</Item>        <Itemname= "Android:windowtitlebackgroundstyle">@style/customwindowtitlebackground</Item>    </style>

You can then refer to the topic in the corresponding activity of androidmanifest.xml.

As follows:

Android Custom title bar

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.