private SpannableString getDistanceString ( String distance , String unit ) { SpannableString spannableString = new SpannableString ( String . format ( "%s %s" , distance , unitStrings . get ( unit ) ) ) ; spannableString . setSpan ( new StyleSpan ( Typeface . BOLD ) , 0 , distance . length ( ) , Spanned . SPAN_EXCLUSIVE_EXCLUSIVE ) ; spannableString . setSpan ( new RelativeSizeSpan ( 0.65f ) , distance . length ( ) + 1 , spannableString . length ( ) , Spanned . SPAN_EXCLUSIVE_EXCLUSIVE ) ; return spannableString ; }
Takes in a distance and units and returns a formatted SpannableString where the number is bold and the unit is shrunked to . 65 times the size