Search in sources :

Example 36 with RelativeSizeSpan

use of android.text.style.RelativeSizeSpan in project MPAndroidChart by PhilJay.

the class PieChartActivity method generateCenterSpannableText.

private SpannableString generateCenterSpannableText() {
    SpannableString s = new SpannableString("MPAndroidChart\ndeveloped by Philipp Jahoda");
    s.setSpan(new RelativeSizeSpan(1.7f), 0, 14, 0);
    s.setSpan(new StyleSpan(Typeface.NORMAL), 14, s.length() - 15, 0);
    s.setSpan(new ForegroundColorSpan(Color.GRAY), 14, s.length() - 15, 0);
    s.setSpan(new RelativeSizeSpan(.8f), 14, s.length() - 15, 0);
    s.setSpan(new StyleSpan(Typeface.ITALIC), s.length() - 14, s.length(), 0);
    s.setSpan(new ForegroundColorSpan(ColorTemplate.getHoloBlue()), s.length() - 14, s.length(), 0);
    return s;
}
Also used : SpannableString(android.text.SpannableString) ForegroundColorSpan(android.text.style.ForegroundColorSpan) StyleSpan(android.text.style.StyleSpan) RelativeSizeSpan(android.text.style.RelativeSizeSpan)

Example 37 with RelativeSizeSpan

use of android.text.style.RelativeSizeSpan in project MPAndroidChart by PhilJay.

the class PieChartFrag method generateCenterText.

private SpannableString generateCenterText() {
    SpannableString s = new SpannableString("Revenues\nQuarters 2015");
    s.setSpan(new RelativeSizeSpan(2f), 0, 8, 0);
    s.setSpan(new ForegroundColorSpan(Color.GRAY), 8, s.length(), 0);
    return s;
}
Also used : SpannableString(android.text.SpannableString) ForegroundColorSpan(android.text.style.ForegroundColorSpan) RelativeSizeSpan(android.text.style.RelativeSizeSpan)

Example 38 with RelativeSizeSpan

use of android.text.style.RelativeSizeSpan in project CoCoin by Nightonke.

the class CoCoinUtil method init.

public static void init(Context context) {
    typefaceLatoRegular = Typeface.createFromAsset(context.getAssets(), "fonts/Lato-Regular.ttf");
    typefaceLatoHairline = Typeface.createFromAsset(context.getAssets(), "fonts/Lato-Hairline.ttf");
    typefaceLatoLight = Typeface.createFromAsset(context.getAssets(), "fonts/LatoLatin-Light.ttf");
    relativeSizeSpan = new RelativeSizeSpan(2f);
    redForegroundSpan = new ForegroundColorSpan(Color.parseColor("#ff5252"));
    greenForegroundSpan = new ForegroundColorSpan(Color.parseColor("#4ca550"));
    whiteForegroundSpan = new ForegroundColorSpan(Color.parseColor("#ffffff"));
    lastColor0 = "";
    lastColor1 = "";
    lastColor2 = "";
    random = new Random();
    MY_BLUE = ContextCompat.getColor(CoCoinApplication.getAppContext(), R.color.my_blue);
}
Also used : ForegroundColorSpan(android.text.style.ForegroundColorSpan) Random(java.util.Random) RelativeSizeSpan(android.text.style.RelativeSizeSpan)

Example 39 with RelativeSizeSpan

use of android.text.style.RelativeSizeSpan in project platform_frameworks_base by android.

the class Notification method removeTextSizeSpans.

private static CharSequence removeTextSizeSpans(CharSequence charSequence) {
    if (charSequence instanceof Spanned) {
        Spanned ss = (Spanned) charSequence;
        Object[] spans = ss.getSpans(0, ss.length(), Object.class);
        SpannableStringBuilder builder = new SpannableStringBuilder(ss.toString());
        for (Object span : spans) {
            Object resultSpan = span;
            if (resultSpan instanceof CharacterStyle) {
                resultSpan = ((CharacterStyle) span).getUnderlying();
            }
            if (resultSpan instanceof TextAppearanceSpan) {
                TextAppearanceSpan originalSpan = (TextAppearanceSpan) resultSpan;
                resultSpan = new TextAppearanceSpan(originalSpan.getFamily(), originalSpan.getTextStyle(), -1, originalSpan.getTextColor(), originalSpan.getLinkTextColor());
            } else if (resultSpan instanceof RelativeSizeSpan || resultSpan instanceof AbsoluteSizeSpan) {
                continue;
            } else {
                resultSpan = span;
            }
            builder.setSpan(resultSpan, ss.getSpanStart(span), ss.getSpanEnd(span), ss.getSpanFlags(span));
        }
        return builder;
    }
    return charSequence;
}
Also used : TextAppearanceSpan(android.text.style.TextAppearanceSpan) RelativeSizeSpan(android.text.style.RelativeSizeSpan) Spanned(android.text.Spanned) SpannableStringBuilder(android.text.SpannableStringBuilder) CharacterStyle(android.text.style.CharacterStyle) AbsoluteSizeSpan(android.text.style.AbsoluteSizeSpan)

Example 40 with RelativeSizeSpan

use of android.text.style.RelativeSizeSpan in project platform_frameworks_base by android.

the class HtmlToSpannedConverter method endHeading.

private static void endHeading(Editable text) {
    // RelativeSizeSpan and StyleSpan are CharacterStyles
    // Their ranges should not include the newlines at the end
    Heading h = getLast(text, Heading.class);
    if (h != null) {
        setSpanFromMark(text, h, new RelativeSizeSpan(HEADING_SIZES[h.mLevel]), new StyleSpan(Typeface.BOLD));
    }
    endBlockElement(text);
}
Also used : StyleSpan(android.text.style.StyleSpan) RelativeSizeSpan(android.text.style.RelativeSizeSpan)

Aggregations

RelativeSizeSpan (android.text.style.RelativeSizeSpan)63 StyleSpan (android.text.style.StyleSpan)32 ForegroundColorSpan (android.text.style.ForegroundColorSpan)21 SpannableString (android.text.SpannableString)18 SpannableStringBuilder (android.text.SpannableStringBuilder)17 CharacterStyle (android.text.style.CharacterStyle)16 AbsoluteSizeSpan (android.text.style.AbsoluteSizeSpan)10 SuperscriptSpan (android.text.style.SuperscriptSpan)10 TypefaceSpan (android.text.style.TypefaceSpan)10 JustifiedSpan (com.bluejamesbond.text.style.JustifiedSpan)9 ArticleBuilder (com.bluejamesbond.text.util.ArticleBuilder)9 SubscriptSpan (android.text.style.SubscriptSpan)8 ImageSpan (android.text.style.ImageSpan)7 StrikethroughSpan (android.text.style.StrikethroughSpan)7 UnderlineSpan (android.text.style.UnderlineSpan)7 LeftSpan (com.bluejamesbond.text.style.LeftSpan)7 SimpleDateFormat (java.text.SimpleDateFormat)7 Context (android.content.Context)6 BackgroundColorSpan (android.text.style.BackgroundColorSpan)6 MyQuoteSpan (com.bluejamesbond.text.sample.helper.MyQuoteSpan)6