/*
* Copyright (C) 2015 Drakeet <drakeet.me@gmail.com>
*
* This file is part of Meizhi
*
* Meizhi is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Meizhi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Meizhi. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sjl.yuehu.util;
import android.content.Context;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.RelativeSizeSpan;
import android.text.style.TextAppearanceSpan;
import android.text.style.TypefaceSpan;
/**
* StringStyleUtil
*/
public class StringStyleUtil {
public static SpannableString format(Context context, String text, int style) {
SpannableString spannableString = new SpannableString(text);
spannableString.setSpan(new TextAppearanceSpan(context, style), 0, text.length(), 0);
return spannableString;
}
public static SpannableString formatNum(Context context, String text) {
SpannableString spannableString = new SpannableString(text);
spannableString.setSpan(new TypefaceSpan("serif"), 0, text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
// spannableString.setSpan(new RelativeSizeSpan(3f), 0, text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
return spannableString;
}
}