It works!
Thanks a lot for sharing your insight :)  :)  :)    My code look as
follows:

        private static final float SMALL_TEXT_RELATIVE_SIZE = 0.6f;

        public CharSequence setSpeedText(){
                        CharSequence text = "km/h";
                SpannableStringBuilder smaller = new
SpannableStringBuilder(text);
                smaller.setSpan(new
RelativeSizeSpan(SMALL_TEXT_RELATIVE_SIZE), 0,
                text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                        CharSequence cs = TextUtils.concat(kMph[DID], smaller);

                return cs;
        }

and the result is displayed beautifully with large "45.6" sitting next
to small "km/h" as I always wanted them to.

Thank you very very much!


On May 6, 3:26 pm, Zsolt Vasvari <[email protected]> wrote:
> Here's the code I use to make an arbitrary CharSequence "smaller"
>
>     private static final float SMALL_TEXT_RELATIVE_SIZE = 0.8f;
>
>     public static CharSequence makeSmaller(CharSequence text)
>     {
>         SpannableStringBuilder smaller = new SpannableStringBuilder(text);
>         smaller.setSpan(new RelativeSizeSpan(SMALL_TEXT_RELATIVE_SIZE), 0,
> text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
>
>         return smaller;
>     }
>
> Once you have the "smaller" text, you can use TextUtils.concat() to build
> up you final text.  Just make sure you nowhere cast/toString() the
> CharSequence to a String because you will lose the formatting info.
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to