Example usage for android.text SpannableString SpannableString

List of usage examples for android.text SpannableString SpannableString

Introduction

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

Prototype

public SpannableString(CharSequence source) 

Source Link

Document

For the backward compatibility reasons, this constructor copies all spans including android.text.NoCopySpan .

Usage

From source file:Main.java

public static SpannableString getDeleteStr(String content) {
    SpannableString sps = new SpannableString(content);
    sps.setSpan(new StrikethroughSpan(), 0, content.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    return sps;/*w  ww .j  a va  2 s.  c  o  m*/
}

From source file:Main.java

public static Spannable createUnderline(String str) {
    SpannableString contentUnderline = new SpannableString(str);
    contentUnderline.setSpan(new UnderlineSpan(), 0, contentUnderline.length(), 0);

    return contentUnderline;
}

From source file:Main.java

public static SpannableString getSpannableString(String str, int firstIndex, int endIndex, Object style) {
    SpannableString spannableString = new SpannableString(str);
    spannableString.setSpan(style, firstIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    return spannableString;
}

From source file:Main.java

public static SpannableString formatTextSize(String txt, int size, int start, int end) {
    SpannableString spanString = new SpannableString(txt);
    AbsoluteSizeSpan span = new AbsoluteSizeSpan(size, true);
    spanString.setSpan(span, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    return spanString;
}

From source file:Main.java

public static CharSequence small(CharSequence sequence) {
    SpannableString spannable = new SpannableString(sequence);
    spannable.setSpan(new RelativeSizeSpan(0.9f), 0, sequence.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    return spannable;
}

From source file:Main.java

public static CharSequence color(int color, CharSequence sequence) {
    SpannableString spannable = new SpannableString(sequence);
    spannable.setSpan(new ForegroundColorSpan(color), 0, sequence.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    return spannable;
}

From source file:Main.java

/**
 * // w ww  . j a va  2 s.c o  m
 * 
 * @param text
 * @return
 */
public static SpannableString strickout(String text) {
    SpannableString ss = new SpannableString(text);
    ss.setSpan(new StrikethroughSpan(), 0, ss.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    return ss;
}

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;/* ww  w. j  a v  a  2  s . c  o  m*/
}

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;/*ww w  . j a v a2 s . c  o  m*/
}

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
}