Use TextView to achieve this effect, picture text mixed, text different color font. Call and hang up the browser and so on
The code is as follows:
@Override
public void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.activity_main);
Mytextview = (TextView) This.findviewbyid (R.ID.IMG_IV);
Create a Spannablestring object
Spannablestring sp = new spannablestring ("This sentence has Baidu hyperlinks, there are highlighting, so, or so, there are italic.");
Set up hyperlinks
Sp.setspan (New Urlspan ("http://www.baidu.com"), 5, 7, spanned.span_exclusive_exclusive);
Set highlight Style One
Sp.setspan (New Backgroundcolorspan (color.red), 19,spannable.span_exclusive_exclusive);
Set the highlight style two Sp.setspan (new Foregroundcolorspan (Color.yellow), 20,24,spannable.span_exclusive_inclusive);
Set italic
Sp.setspan (New Stylespan (Android.graphics.Typeface.BOLD_ITALIC), spannable.span_exclusive_inclusive);
Call
Sp.setspan (New Urlspan ("tel:4155551212"), 2, 5,spanned.span_exclusive_exclusive);
The picture shows in TextView.
drawable d = getresources (). getdrawable (R.drawable.ic_launcher);
D.setbounds (0, 0, d.getintrinsicwidth (), D.getintrinsicheight ());
Imagespan span = new Imagespan (d, Imagespan.align_baseline);
Sp.setspan (span, 0, 1, spannable.span_inclusive_exclusive);
Spannablestring Object Set to TextView
Mytextview.settext (SP);
Set TextView to click
Mytextview.setmovementmethod (Linkmovementmethod.getinstance ());
}
Android TextView to achieve text-to-picture mixing effect