I have an app which adds a small graphic next to the title of a tab in the action bar by using a custom view and setting an ImageSpan
into the text, see below.
private void NotifyTab ( int state )
{
Console.WriteLine("Notifying tab " + state );
var tab = SupportActionBar.GetTabAt( state ).CustomView as TextView;
String title;
if ( ARTIST == state )
{
title = GetString( Resource.String.menu_artists );
}
else
{
title = GetString( Resource.String.menu_friends );
}
SpannableString text = new SpannableString( " " + title );
ImageSpan icon = new ImageSpan( this, Resource.Drawable.ico_indicator, SpanAlign.Baseline );
text.SetSpan( icon, 0, 1, SpanTypes.InclusiveInclusive );
tab.SetText( text, TextView.BufferType.Spannable );
}
This code was working fine until I applied the same styling to the tab as the actionbar tabs use Widget.Sherlock.ActionBar.TabText
as soon as I did this the ImageSpan
stopped working.
Does anyone know what attribute causes this and if there is a workaround? I'm wondering if it's caused by the forced use of all caps, or the serif font.
Solved, it turns out
<item name="android:textAllCaps">true</item>
Is the guilty party, when removed the ImageSpan
shows up. A simple workaround is to make the string resources capitalised and the problem is gone.