Code example for RelativeSizeSpan

0
        int level = intent.getIntExtra("level", 0);
        String battery = Integer.toString(level) + "%";
 
        SpannableStringBuilder BattText = new SpannableStringBuilder(battery);
        int percent = battery.indexOf("%");
        CharacterStyle style = new RelativeSizeSpan(0.7f);
        BattText.setSpan(style, percent, percent + 1, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
        setText(BattText);
    } 
 
    // Get text colors 
    final void updateTextColor(Intent intent) {
        ContentResolver resolver = mContext.getContentResolver();
        int level = intent.getIntExtra("level", 0);
        boolean plugged = intent.getIntExtra("plugged", 0) != 0;
 
        if (!mBattColorAllow) {
            mBattTextColor = Settings.System.getInt(resolver, Settings.System.BATTERY_TEXT_COLOR_STOCK, 0xFF33B5E5);
        } else if (plugged) {
            mBattTextColor = Settings.System.getInt(resolver, Settings.System.BATTERY_TEXT_COLOR_CHARGE, 0xFF00FF00);
        } else if (level > 15) {