Example usage for android.text.style StyleSpan StyleSpan

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

Introduction

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

Prototype

public StyleSpan(@NonNull Parcel src) 

Source Link

Document

Creates a StyleSpan from a parcel.

Usage

From source file:Main.java

public static SpannableString bold(SpannableString sequence) {
    sequence.setSpan(new StyleSpan(Typeface.BOLD), 0, sequence.length(), 0);
    return sequence;
}

From source file:Main.java

public static CharSequence setTextStyleBold(CharSequence text) {
    final StyleSpan style = new StyleSpan(Typeface.BOLD);
    final SpannableString str = new SpannableString(text);
    str.setSpan(style, 0, text.length(), 0);

    return str;/*from  ww w.j  a  v a2 s .  com*/
}

From source file:Main.java

public static CharSequence setTextStyleNormal(CharSequence text) {
    final StyleSpan style = new StyleSpan(Typeface.NORMAL);
    final SpannableString str = new SpannableString(text);
    str.setSpan(style, 0, text.length(), 0);

    return str;/*from  w w  w .  jav a 2 s.  c  o m*/
}

From source file:Main.java

public static SpannableStringBuilder applyBoldStyle(String text) {
    SpannableStringBuilder ss = new SpannableStringBuilder(text);
    ss.setSpan(new StyleSpan(Typeface.BOLD), 0, text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    return ss;/*  www .j  a  v a 2s .  co  m*/
}

From source file:Main.java

public static SpannableString stylePartTextBold(CharSequence text, int start, int end) {
    SpannableString span = new SpannableString(text);
    span.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), start, end, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
    return span;//from  w  ww .  j  ava 2 s. com
}

From source file:Main.java

/**
 * Apply bold span to a spannable string.
 *///from  ww w. j a  v  a2 s. c o m
public static void applyBoldSpan(Spannable spannable, int startIndex, int endIndex) {

    StyleSpan bold = new StyleSpan(android.graphics.Typeface.BOLD);

    spannable.setSpan(bold, startIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}

From source file:Main.java

public static CharSequence bold(CharSequence sequence) {
    SpannableString spannable = new SpannableString(sequence);
    spannable.setSpan(new StyleSpan(Typeface.BOLD), 0, sequence.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    return spannable;
}

From source file:Main.java

public static CharSequence italic(CharSequence sequence, int length) {
    SpannableString spannable = new SpannableString(sequence);
    spannable.setSpan(new StyleSpan(android.graphics.Typeface.ITALIC), 0, length,
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    return spannable;
}

From source file:Main.java

/**
 * Returns a CharSequence that applies boldface to the concatenation
 * of the specified CharSequence objects.
 *//*from   w ww .ja v  a 2s.co  m*/
public static CharSequence bold(CharSequence... content) {
    return apply(content, new StyleSpan(Typeface.BOLD));
}

From source file:Main.java

public static SpannableString setTextBold(String content, int startIndex, int endIndex) {
    if (TextUtils.isEmpty(content) || startIndex < 0 || endIndex >= content.length()
            || startIndex >= endIndex) {
        return null;
    }//from w  w  w. j av a2s  . co m

    SpannableString spannableString = new SpannableString(content);
    spannableString.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), startIndex, endIndex,
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    return spannableString;
}