1

I changed tha status bar's color from styles.xml:

<resources>

<color name="custom_theme_color">#42A5F5</color>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->

    <item name="colorPrimaryDark">@color/custom_theme_color</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

I also change the status bar's title from string.xml:

<resources>

<string name="app_name">Qu-easy</string>
<item name="colorPrimaryDark">@color/custom_theme_color</item>
</resources>

How can i set the title to the center of status bar? I guess something like gravity.center?

  • Make custome Action bar about this and than cener the title refer this accepted answer http://stackoverflow.com/questions/18418635/how-to-align-title-at-center-of-actionbar-in-default-themetheme-holo-light – Jhaman Das Apr 24 '16 at 12:25

1 Answers1

0

try this one :-
Here you need to add one xml file
write following code in onCreate method

getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getSupportActionBar().setCustomView(R.layout.custom_actionbar);
ActionBar.LayoutParams p = new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
p.gravity = Gravity.CENTER;

custom_actionbar.xml Layout

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="vertical"
android:gravity="center"
android:layout_gravity="center">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:text="XYZ"
    android:textColor="#ffffff"
    android:id="@+id/mytext"
    android:textSize="30dp"
    android:textStyle="bold"/>

</LinearLayout>

This will definitely work for you

ojus kulkarni
  • 1,877
  • 3
  • 25
  • 41