Android往TextView文字最后添加一个图片
2017-11-07 本文已影响109人
你在笑吗
tv1 = (TextView) findViewById(R.id.tv1);
tv2 = (TextView) findViewById(R.id.tv2);
Bitmap bitmap = BitmapFactory.decodeResource(getApplication().getResources(), R.mipmap.ic_launcher);
ImageSpan imgSpan = new ImageSpan(getApplicationContext(), bitmap);
SpannableString spanString = new SpannableString("icon");
spanString.setSpan(imgSpan, 0, 4, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
tv1.append(spanString);
tv2.append(spanString);