Example usage for android.text.style ImageSpan ImageSpan

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

Introduction

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

Prototype

public ImageSpan(@NonNull Drawable drawable) 

Source Link

Document

Constructs an ImageSpan from a drawable with the default alignment DynamicDrawableSpan#ALIGN_BOTTOM .

Usage

From source file:cm.aptoide.com.actionbarsherlock.widget.SearchView.java

private CharSequence getDecoratedHint(CharSequence hintText) {
    // If the field is always expanded, then don't add the search icon to the hint
    if (!mIconifiedByDefault)
        return hintText;

    SpannableStringBuilder ssb = new SpannableStringBuilder("   "); // for the icon
    ssb.append(hintText);//  w w w .  j  a  va  2 s  . co m
    Drawable searchIcon = getContext().getResources().getDrawable(getSearchIconId());
    int textSize = (int) (mQueryTextView.getTextSize() * 1.25);
    searchIcon.setBounds(0, 0, textSize, textSize);
    ssb.setSpan(new ImageSpan(searchIcon), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    return ssb;
}

From source file:com.tandong.sa.sherlock.widget.SearchView.java

private CharSequence getDecoratedHint(CharSequence hintText) {
    // If the field is always expanded, then don't add the search icon to
    // the hint/* w w w.  j  av  a 2  s . c om*/
    if (!mIconifiedByDefault)
        return hintText;

    SpannableStringBuilder ssb = new SpannableStringBuilder("   "); // for
    // the
    // icon
    ssb.append(hintText);
    Drawable searchIcon = getContext().getResources().getDrawable(getSearchIconId());
    int textSize = (int) (mQueryTextView.getTextSize() * 1.25);
    searchIcon.setBounds(0, 0, textSize, textSize);
    ssb.setSpan(new ImageSpan(searchIcon), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    return ssb;
}