我有一个应用程序,它通过使用自定义视图并将ImageSpan设置到文本中,在操作栏中的选项卡标题旁边添加了一个小图形,参见下面。
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 );
}这段代码运行良好,直到我对制表符应用了与actionbar选项卡使用Widget.Sherlock.ActionBar.TabText相同的样式,这样做之后,ImageSpan就停止工作了。
有人知道是什么属性导致了这种情况吗?如果有解决办法的话?我想知道它是由强制使用所有大写还是衬线字体造成的。
发布于 2013-08-16 12:39:19
解决了,事实证明
<item name="android:textAllCaps">true</item>是有罪的一方,当ImageSpan被移除时就会出现。一个简单的解决办法是将字符串资源资本化,问题就解决了。
https://stackoverflow.com/questions/18271269
复制相似问题