There are pictures in the Android TextView with a mixed text arrangement
1. Using html.fromhtml
2. New Imagegetter
3. Using the label
Demo
1. Set text
((TextView) Findviewbyid (R.id.tv_gradlist_calorie_desc)). SetText (Html . fromhtml (Descstring (), Getimagegetterinstance (), null));
2. Get text
/** * String * * @return * /private string descstring () { return "The total calories you consume is approximately equal to 4 cups" + " "+" "; }
3.imagegetter
/** * imagegetter for text mixed * * @return * /public imagegetter getimagegetterinstance () { Imagegetter imggetter = new Html.imagegetter () { @Override public drawable getdrawable (String source) { int Fonth = (int) (Getresources (). Getdimension ( r.dimen.textsizemedium) * 1.5); int id = integer.parseint (source); drawable d = getresources (). getdrawable (ID); int height = fonth; int width = (int) ((float) d.getintrinsicwidth ()/(float) d . Getintrinsicheight ()) * fonth; if (width = = 0) { width = d.getintrinsicwidth (); } D.setbounds (0, 0, width, height); return D; } ; return imggetter; }
Effect