Is it possible to center the title on an AnctionBar android using style.xml?

I would like to focus my application name displayed in an ActionBar. So far, I have adjusted my background color using only the style.xml file, for example:

<!-- Application theme. --> <style name="AppTheme" parent="@android:style/Theme.Holo.Light"> <!-- All customizations that are NOT specific to a particular API-level can go here. --> <item name="android:actionBarStyle">@style/MyActionBar</item> </style> <style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar"> <item name="android:background">@drawable/action_bg</item> <item name="android:layout_gravity">center</item> </style> 

But it will not center the title if I try to add:

 <item name="android:layout_gravity">center</item> 

I found a hack where ( here ) we can create and load a separate "actionbar.xml" for additional settings in the onCreate method, and it works, but when you start the application it takes 1-2 seconds to load this xml while the original action panel is displayed .

Is there no other solution to costumize the action bar (adding an image logo, center text, etc.) in style.xml? Does this need to be done programmatically?

Thank!!

+2
xml text center android-actionbar
Jan 15 '14 at 7:26
source share

No one has answered this question yet.

See similar questions:

37
How to align title in ActionBar center in default theme (Theme.Holo.Light)

or similar:

862
What are the β€œtools: context” in Android layout files?
507
Android: combining text and images on Button or ImageButton
389
How to change text to bold in Android?
375
Web colors in Android xml resource file
337
Cannot find Theme.AppCompat.Light for new Android ActionBar support
247
How to set custom font in ActionBar header?
182
How to change the title and icon of the Android taskbar
113
align text center using android
2
android / view / view $ onUnhandledKeyEventListener (onMeasure error)
0
onOptionsItemSelected not called for Up button in Android 4.0.3



All Articles