目前我有一个像这样的spannableString,图标位于标题字符串的左侧。问题是,有没有办法让图标在字符串上方,而图标是对齐中心?如何将SpannableString修改为字符串下方的图标?
样品是这样的:
[] <==== This is the icon
TitleTest <=== This is the title
ABCD
感谢
这里是我的代码尝试:
Drawable image = context.getResources().getDrawable(R.drawable.ic_launcher);
image.setBounds(0, 0, image.getIntrinsicWidth(), image.getIntrinsicHeight());
// Replace blank spaces with image icon
SpannableString sb = new SpannableString(" " + tabTitles[position]);
ImageSpan imageSpan = new ImageSpan(image, ImageSpan.ALIGN_BASELINE);
sb.setSpan(imageSpan, 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return sb;
感谢您的帮助