I want to center the title in the Actionbar. I have created a custom layout for that it does comes up in the center if home icon is visible but if that is set to false then the title shifts to the left thus not coming up in center.
The actionbar should only have title and menu options and no home icon which will take the user back to the previous screen. I have even tried giving left margin to it but still it doesn't work.
Is there any workaround for this??
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/txtTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:ellipsize="end"
android:maxLines="1"
android:text="@string/app_name"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/white"
android:textSize="@dimen/title_size" />
</RelativeLayout>