set Type Face - Android android.text

Android examples for android.text:SpannableString

Description

set Type Face

Demo Code

import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.AbsoluteSizeSpan;
import android.text.style.BackgroundColorSpan;
import android.text.style.ForegroundColorSpan;
import android.text.style.RelativeSizeSpan;
import android.text.style.StrikethroughSpan;
import android.text.style.StyleSpan;
import android.text.style.SubscriptSpan;
import android.text.style.SuperscriptSpan;
import android.text.style.TypefaceSpan;
import android.text.style.UnderlineSpan;

public class Main{

    /**/*  w ww . ja v  a 2  s. c o m*/
     * @param source
     * @param start
     * @param end
     * @param mode
     * @return
     */
    public static SpannableString setTypeFace(CharSequence source,
            int start, int end, TypeFaceMode mode) {
        if (source == null) {
            return null;
        }
        SpannableString sp = new SpannableString(source);
        sp.setSpan(new TypefaceSpan(getTypeFaceMode(mode)), start, end,
                FLAGS);
        return sp;
    }

}

Related Tutorials