我将imagedrawable设置为TextView的SpannableString,但图像比文本大,使其看起来很奇怪。我需要减小imagespan的大小,使其与文本
的高度相同这是我尝试过的:
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
SpannableStringBuilder builder = new SpannableStringBuilder(holder.temptext.getText());
builder.setSpan(new ImageSpan(drawable), selectionCursor - ":)".length(), selectionCursor, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
holder.temptext.setText(builder);
holder.temptext.setSelection(selectionCursor);
holder.caption.setText(builder);
你需要测量你的TextView
的高度,并使用它来代替内在界限:
int lineHeight = holder.temptext.getLineHeight();
drawable.setBounds(0, 0, lineHeight, lineHeight);