How to find the text size for a given rectangle?
I have a doubt. How to find the max text size开发者_运维百科 to a text for a given rectangle. Consider the rectangle width and height is 100,50 respectively. how to find a text size which almost fits the rectangle.
Thanks in advance.
Can't you just add a Grid to the rectangle. and Add a TextBlock in the Grid so the any text within the TextBlock would size with the rectangle.
<Rectangle>
<Grid><TextBlock></TextBlock></Grid>
</Rectangle>
If you create an android.text.Layout.StaticLayout
specifying the font and width, and check the height. You can use this to do a binary search for the text size that best fits your rectangle.
You might want to also check that no individual line has too much padding on one end (think right-to-left language support if you add this check).
精彩评论