Right now the title of my activity shows to the left as < Title
and then the other menu item shows to the right. I want to center my title and leave out the <
. How do I do that? I am using typical menu which I call using
public boolean onOptionsItemSelected(MenuItem item)
and
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.yesterday, menu);
return true;
}
EDIT:
I managed to get it to show using
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.activity_yesterday);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.yesterday_title_bar);
where yesterday_title_bar
is a relativeLayout
But it's showing half the height of the views. So I created the following style. But when I apply the style in the manifest. The manifest says it cannot find the resource.
<style name="CustomWindowTitleBackground">
<item name="android:background">#323331</item>
</style>
<style name="CustomTheme" parent="android:Theme">
<item name="android:windowTitleSize">65dip</item>
<item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
</style>
Manifest:
<activity
android:name="com.company.YesterdayActivity"
android:theme="@android:style/CustomTheme" >
</activity>
Just use a custom view for your actionbar in your activity...
The view could probably be something like this:
I also used actionbar sherlock and i set header position by this method. you can set a custom textview and can set its gravity to center. use the below method and tell me.
and here is the layout i used:
The theme is not in android: style but in style. Change your manifest to this..
EDIT: Maybe it's your parent theme. What was your theme before? Try changing your parent theme like this: