简体   繁体   中英

Android custom title bar

I have been trying to do my custom title bar for a week.

I have tried approximately 30 suggestions to achieve that but nothing worked.

I get the you cannot combine custom titles with other title features error every time whatever I try. I can't get rid of this error. This driving me mad.

I have also tried to find a solution by looking for the error on Google. It also did not work.

Here is the code I've tried:

this.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.activity_main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.my_custom_title);

I don't know how to achieve a custom title bar.

Much thanks for helps in advance.

Not the best way to do it in my opinion.

You should do, in res/values/styles.xml, something like:

<style name="AppBaseTheme" parent="...">
    <item name="android:actionBarStyle">@style/mActionBar</item>
</style>

<style name="mActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
        <item name="android:background">...</item>
        <item name="android:icon">...</item>
        <item name="android:titleTextStyle">...</item>
</style>

I recently faced the same error while implementing a custom title bar..."you cannot combine custom titles with other title features"

According to You cannot combine custom title with other title features , Holo's title bar is displayed if the project uses Holo theme.

I stripped my project of all code that uses Holo, and after that my custom title bar displayed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM