3
我的問題與描述的here非常相似。但只有在Android 4.2設備上測試時纔會出現。在使用Android 2.2的舊版測試設備上,一切都很順利。ImageSpan在Android 4.2中移除以下文本Jelly Bean
我的問題
我在一個TextView其外殼更換TextView中的一個字符的中間增加一個ImageSpan。在Android 4.2 將不會顯示ImageSpan後的文字。在Android 2.2上,一切都如預期般運作。
代碼示例
CharSequence chars = txtView.getText();
SpannableStringBuilder stringBuilder = new SpannableStringBuilder(chars);
for (int i = 0; i < chars.length(); i++) {
int codePoint = Character.codePointAt(chars, i);
if (codePoint > 255) {
// loading the bitmap ...
ImageSpan img = new ImageSpan(context, bmp, ImageSpan.ALIGN_BASELINE);
stringBuilder.replace(i, i + 1, "");
stringBuilder.setSpan(img, i, i + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
txtView.setText(stringBuilder, BufferType.SPANNABLE);
截圖
我到目前爲止已經試過
我幾乎試過任何Spanned - 你可以在setSpan
上添加,但在4.2設備上沒有任何作用。