Search code examples
androidandroid-actionbaractionbarsherlock

Application label font not preserved on orientation change


I am not able to preserve the font for my application label on screen orientation change. Currently I am setting the font using the below code in the onCreate method of SherlockFragmentActivity.

titleId = Resources.getSystem().getIdentifier("action_bar_title", "id", "android");
if(titleId == 0)
    titleId = com.actionbarsherlock.R.id.abs__action_bar_title; 
mAppName = (TextView) findViewById(titleId);
Typeface face = Typeface.createFromAsset(getAssets(), "fonts/handsean.ttf");
mAppName.setTypeface(face);

On Orientation change the font reverts back to the default. I tried preserving state using manifest.xml but it didnot help. it preserves everything except the label font. Can someone suggest how this can be done ?

Thanks for stopping by and reading this post.


Solution

  • Did you tried setting android:configChanges="orientation" and handling the orientation change with onConfigurationChanged()?

    edit: also explained here why it's not functioning.