Method One: Rewrite TextView's OnDraw method, but also very intuitive is not very good control after displaying the picture and then display the position of the space occupied by the font. It is generally assumed that the font is overlapping on the picture recommended for this write. Time relationship, this does not pay the source code.
Method Two: Using TextView to support the features of some HTML. Use the API to assign pictures directly. The code is as follows:
The first method displays the picture in TextView, string html = "
Note the following sentence: String html = "
Method Three: Use Imagespan and spannablestring. The code is as follows:
The 2nd method displays the picture in TextView bitmap B = Bitmapfactory.decoderesource (Getresources (), R.drawable.hanguo); Imagespan Imgspan = New Imagespan (this, b); spannablestring spanstring = new spannablestring ("icon") Spanstring.setspan (Imgspan, 0, 4, spannable.span_exclusive_ EXCLUSIVE, Textview2.settext (spanstring); Textview2.append (Xinhua Beijing, April 27, according to CCTV reports, South Korea's prime Minister Zheng Bake in the local time 27th morning, announced the meeting, said that his response to the Korean "years "The wreck was responsible, announcing his resignation and hoping that the family would forgive and understand his decision." ");
Such a method is the most intuitive. Gets the Imagespan object by bitmap or Drawable object. To create a new Spannablestring object, set the contents of the span to OK. In fact, spannablestring is very powerful, such as in the EditText will be part of the text highlighting, underline, italic, insert expression can use it, see Links: http://gundumw100.iteye.com/blog/904107
http://blog.csdn.net/rockcoding/article/details/7231756
Next, the upper and lower pictures correspond to another and the third method:
Three ways to display images directly in Android TextView