Search in sources :

Example 31 with ImageSpan

use of android.text.style.ImageSpan in project android_frameworks_base by ResurrectionRemix.

the class SearchView method getDecoratedHint.

private CharSequence getDecoratedHint(CharSequence hintText) {
    // then don't add the search icon to the hint.
    if (!mIconifiedByDefault || mSearchHintIcon == null) {
        return hintText;
    }
    final int textSize = (int) (mSearchSrcTextView.getTextSize() * 1.25);
    mSearchHintIcon.setBounds(0, 0, textSize, textSize);
    final SpannableStringBuilder ssb = new SpannableStringBuilder("   ");
    ssb.setSpan(new ImageSpan(mSearchHintIcon), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    ssb.append(hintText);
    return ssb;
}
Also used : SpannableStringBuilder(android.text.SpannableStringBuilder) ImageSpan(android.text.style.ImageSpan)

Example 32 with ImageSpan

use of android.text.style.ImageSpan in project android_frameworks_base by ResurrectionRemix.

the class RecentsCreateFragment method appendDrawable.

private static void appendDrawable(SpannableStringBuilder b, Drawable d) {
    final int length = b.length();
    b.append("〉");
    b.setSpan(new ImageSpan(d), length, b.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
Also used : ImageSpan(android.text.style.ImageSpan)

Example 33 with ImageSpan

use of android.text.style.ImageSpan in project UltimateAndroid by cymcsg.

the class PagerTitleStrip method changeSpanString.

//    Handler textHandler=new Handler(){
//        /**
//         * Subclasses must implement this to receive messages.
//         *
//         * @param msg
//         */
//        @Override
//        public void handleMessage(Message msg) {
//            super.handleMessage(msg);
//            if (msg.what==1){
//                Bundle bundle=msg.getData();
//                mCurrText.setText(
//                        changeSpanString(bundle.getString("string"), bundle.getInt("int"), 1) );
//            }else{
//                mCurrText.setText(null);
//            }
//        }
//    };
SpannableString changeSpanString(String temp, int position, int color) {
    try {
        temp = temp.replaceAll("-", " - ");
        SpannableString ss = new SpannableString(temp);
        Matrix matrix = new Matrix();
        matrix.postRotate(180);
        Bitmap bitmaporg = BitmapFactory.decodeResource(getResources(), R.drawable.ico_arrow2x);
        if (color == 2) {
            bitmaporg = BitmapFactory.decodeResource(getResources(), R.drawable.ico_arrow_grey2x);
        }
        Bitmap resizedBitmap = Bitmap.createBitmap(bitmaporg, 0, 0, bitmaporg.getWidth(), bitmaporg.getHeight(), matrix, true);
        BitmapDrawable bmd = new BitmapDrawable(getResources(), resizedBitmap);
        BitmapDrawable bm = new BitmapDrawable(getResources(), bitmaporg);
        Drawable drawable = position == 0 ? bm : bmd;
        drawable.setBounds(0, 0, drawable.getIntrinsicWidth() * 12 / 10, drawable.getIntrinsicHeight() * 12 / 10);
        ImageSpan imageSpan = new ImageSpan(drawable, ImageSpan.ALIGN_BASELINE);
        ss.setSpan(imageSpan, temp.indexOf("-"), temp.indexOf("-") + 1, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        return ss;
    } catch (Exception e) {
        e.printStackTrace();
        Logs.e(e, "");
        return null;
    }
}
Also used : SpannableString(android.text.SpannableString) Bitmap(android.graphics.Bitmap) Matrix(android.graphics.Matrix) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ImageSpan(android.text.style.ImageSpan)

Example 34 with ImageSpan

use of android.text.style.ImageSpan in project DanmakuFlameMaster by Bilibili.

the class UglyViewCacheStufferSampleActivity method createSpannable.

private SpannableStringBuilder createSpannable(Drawable drawable) {
    String text = "bitmap";
    SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(text);
    //ImageSpan.ALIGN_BOTTOM);
    ImageSpan span = new ImageSpan(drawable);
    spannableStringBuilder.setSpan(span, 0, text.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
    spannableStringBuilder.append("图文混排");
    spannableStringBuilder.setSpan(new BackgroundColorSpan(Color.parseColor("#8A2233B1")), 0, spannableStringBuilder.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
    return spannableStringBuilder;
}
Also used : SpannableStringBuilder(android.text.SpannableStringBuilder) BackgroundColorSpan(android.text.style.BackgroundColorSpan) ImageSpan(android.text.style.ImageSpan)

Example 35 with ImageSpan

use of android.text.style.ImageSpan in project android_frameworks_base by DirtyUnicorns.

the class RestrictedLockUtils method removeExistingRestrictedSpans.

private static void removeExistingRestrictedSpans(SpannableStringBuilder sb) {
    final int length = sb.length();
    RestrictedLockImageSpan[] imageSpans = sb.getSpans(length - 1, length, RestrictedLockImageSpan.class);
    for (ImageSpan span : imageSpans) {
        final int start = sb.getSpanStart(span);
        final int end = sb.getSpanEnd(span);
        sb.removeSpan(span);
        sb.delete(start, end);
    }
    ForegroundColorSpan[] colorSpans = sb.getSpans(0, length, ForegroundColorSpan.class);
    for (ForegroundColorSpan span : colorSpans) {
        sb.removeSpan(span);
    }
}
Also used : ForegroundColorSpan(android.text.style.ForegroundColorSpan) ImageSpan(android.text.style.ImageSpan)

Aggregations

ImageSpan (android.text.style.ImageSpan)98 SpannableStringBuilder (android.text.SpannableStringBuilder)53 Drawable (android.graphics.drawable.Drawable)29 ForegroundColorSpan (android.text.style.ForegroundColorSpan)23 BackgroundColorSpan (android.text.style.BackgroundColorSpan)14 TextView (android.widget.TextView)14 SpannableString (android.text.SpannableString)12 View (android.view.View)11 UnderlineSpan (android.text.style.UnderlineSpan)10 RelativeSizeSpan (android.text.style.RelativeSizeSpan)7 StyleSpan (android.text.style.StyleSpan)7 Bitmap (android.graphics.Bitmap)6 LinearLayout (android.widget.LinearLayout)6 Application (android.app.Application)5 AbsoluteSizeSpan (android.text.style.AbsoluteSizeSpan)5 CharacterStyle (android.text.style.CharacterStyle)5 SuggestionSpan (android.text.style.SuggestionSpan)5 URLSpan (android.text.style.URLSpan)5 MenuItem (android.view.MenuItem)5 Button (android.widget.Button)5