Hello everyone,
I have these requirements:

- size text to fill the entire length of a TextView, without wrap.
- the text consists of strings of different sizes, such as:
012<big>345</big>6789

To do this I'm using a SpannableStringBuilder.
Get a result as the example is relatively simple.
What I can not do, is calculate the text width in pixels.
I need this because if the the text was too long, I must reduce the
font size so as not to wrap the string.
I found references to the Paint.measureText function, which actually
should be doing what I need and give me the length of text in pixels.
But it does not refer to the various font sizes that compose the text,
but refers to the font size of the TextView to the whole string.
For example:

LinearLayout text = (LinearLayout) findViewById(R.id.LinearLayout);

Str = new SpannableStringBuilder SpannableStringBuilder
("0123456789");
str.setSpan(new RelativeSizeSpan(2f), 3, 6,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

TextView tmp = new TextView(this);
tmp.setText (str, BufferType.SPANNABLE);
text.addView(tmp);

Float dim = tmp.getPaint (). MeasureText (str, 0, str.length ()

If you change the relative size and instead of 2f you put 3f, the
result of MeasureText function remains the same.

You have no idea how to do?
Thanks

-- 
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