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:
<style name="AppTheme" parent="@android:style/Theme.Holo.Light"> <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!!
xml text center android-actionbar
Edmond Tamas Jan 15 '14 at 7:26 2014-01-15 07:26
source share