Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 433
JustWork Avatar asked Dec 06 '25 06:12

JustWork


1 Answers

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>
like image 199
Romain Pellerin Avatar answered Dec 08 '25 20:12

Romain Pellerin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!