Android: Custom Title Bar

Android: Custom Title Bar

I had the same issue as you.

The issue is with something you have in your style.

Try this out:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="My_Theme">
<item name="android:windowTitleSize">35dp</item>
<item name="android:windowTitleBackgroundStyle">@android:color/black</item>
</style>
</resources>

Android - Customizing the title bar

According to this article, you should create a custom style for this. See if it works for you.

Android custom title bar

Not the best way to do it in my opinion.

You should do, in res/values/styles.xml, something like:

<style name="AppBaseTheme" parent="...">
<item name="android:actionBarStyle">@style/mActionBar</item>
</style>

<style name="mActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">...</item>
<item name="android:icon">...</item>
<item name="android:titleTextStyle">...</item>
</style>

set title bar name of a activity

Not sure you can do it your way or not but you can use the bellow solution:

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.your_activity);

final ActionBar actionBar = getActionBar();

// actionBar
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);

// titleTextView
TextView titleTextView = new TextView(actionBar.getThemedContext());

titleTextView.setText("Title");
titleTextView.setTypeface( your_typeface);

titleTextView.setOtherProperties();

// Add titleTextView into ActionBar
actionBar.setCustomView(titleTextView);

}

By doing this solution, you have FULL control of your textview title.

Default title bar displayed before my custom title bar appears

If found a workaround for my problem using Modge's link about splashscreen.

It doesn't solve the problem itself but remains a good workaround.

I created a small activity in charge of the splash screen, avoiding the white first screen to stay for too long. Then this splash redirect on my main activity.

This is also useful in my case since I can start some connection process during the splash screen. You can follow this example: http://www.androidhive.info/2013/07/how-to-implement-android-splash-screen-2/

Add custom title bar using ActionBar

Showing the tabs above your custom layout is the intended default behaviour. Though there are ways to override this. I found to post with possible solutions: #1 and #2

Further more the sherlock actionbar seems to behave the same way.



Related Topics



Leave a reply



Submit