Search code examples
androidandroid-actionbarandroid-actionbar-compat

ActionBarCompat change effect in Android


I'm developing an App using Google's UI design guidelines, so I want to implement the ActionBar.

It must run on 2.2 so I decided to use the ActionBarCompat example.

Instead of using the iosched one, where the action bar is a layout included in an XML file, I decided to implement this using a helper:

public void onCreate(Bundle savedInstanceState) {
  mActivity.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); 
}

public void onPostCreate(Bundle savedInstanceState) {
  mActivity.getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
    R.layout.actionbar_compat);
  setupActionBar();
}

The problem is that, when my app is loading, it displays the default TitleBar and then, it changes to mine, so, there is an ugly effect...

Any way to avoid it?

Thank You!!


Solution

  • It's because the default theme of an application have the title bar and the theme is loaded before you run onCreate() method.

    So, you need to change the theme of your activity (or your application) in the Manifest file with a theme that have no title bar.

    For exemple :

        <activity
            android:name=".MyActivity"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.Light.NoTitleBar" >