Example usage for android.text.style ImageSpan getDrawable

List of usage examples for android.text.style ImageSpan getDrawable

Introduction

In this page you can find the example usage for android.text.style ImageSpan getDrawable.

Prototype

@Override
    public Drawable getDrawable() 

Source Link

Usage

From source file:Main.java

public static CharSequence addIcon(CharSequence total, BitmapDrawable bitmapDrawable, int height) {
    SpannableString string = new SpannableString("  ");
    ImageSpan imageSpan = new ImageSpan(bitmapDrawable);

    int width = (int) (height
            / (bitmapDrawable.getIntrinsicHeight() / (float) bitmapDrawable.getIntrinsicWidth()));

    imageSpan.getDrawable().setBounds(0, 0, width, height);
    string.setSpan(imageSpan, 0, 1, 0);//w w w .jav a2  s .c o m
    if (total == null) {
        return string;
    } else {
        return TextUtils.concat(total, string);
    }
}

From source file:com.forrestguice.suntimeswidget.SuntimesUtils.java

public static ImageSpan createImageSpan(ImageSpan other) {
    Drawable drawable = null;/*www  .ja  va  2 s  .  c  o m*/
    if (other != null)
        drawable = other.getDrawable();

    return new ImageSpan(drawable);
}