Android examples for Graphics:Spannable
get Image Span
/* /*from w ww .ja v a 2 s . co m*/ * @(#)SpannableStringUtils.java Created on 2013-11-11 * Copyright (c) 2013 ZDSoft Networks, Inc. All rights reserved. * $Id$ */ import android.content.Context; import android.graphics.Bitmap; import android.net.Uri; import android.text.Spannable; import android.text.SpannableString; import android.text.style.AbsoluteSizeSpan; import android.text.style.BackgroundColorSpan; import android.text.style.CharacterStyle; import android.text.style.ForegroundColorSpan; import android.text.style.ImageSpan; import android.text.style.StrikethroughSpan; import android.text.style.StyleSpan; import android.text.style.UnderlineSpan; import android.view.View.OnClickListener; import com.example.bigapple_demo.utils.textviewhtml.SimpleURLSpan.UrlSpanOnClickListener; public class Main{ public static SpannableString getImageSpan(Context context, String text, Bitmap bitmap) { SpannableString spanString = new SpannableString(text); spanString.setSpan(new ImageSpan(context, bitmap), 0, text.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); return spanString; } public static SpannableString getImageSpan(Context context, String text, int resid) { SpannableString spanString = new SpannableString(text); spanString.setSpan(new ImageSpan(context, resid), 0, text.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); return spanString; } public static SpannableString getImageSpan(Context context, String text, Uri uri) { SpannableString spanString = new SpannableString(text); spanString.setSpan(new ImageSpan(context, uri), 0, text.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); return spanString; } }