Now let me throw a spanner into your work. Do some UX testing (grab a few
people that haven't seen the app before) and present them with either of
two versions, one version with the big number and small "km/h" string, and
the other version with just the number. You will find that your app doesn't
need the "km/h" string. It adds no value. Remember the principle of good
design. Less is more.
On Sunday, May 6, 2012 3:53:17 AM UTC-4, x300 wrote:
> 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