Reputation: 1291
I am trying to make a sign (the ones that drivers use at the airport to find someone "Mr Smith") and I wanted the sign to have the largest Font size possible, (its for a tablet), I could write a function to change the size depending on the length of the Text but is there a way of doing natively/better?
Thanks
Upvotes: 1
Views: 990
Reputation: 15257
The most flexible way is to create a custom view that draws the text in onDraw()
. When drawing the text (with one of Canvas.drawText()
) you will have to provide a Paint, and that would let you know the precise length of text, not just length of string (see Paint.measureText()
).
This way you would have plenty of ways to calculate and redistribute the space (and it would totally rely on you how).
One way I can think of is calculating the length for a huge font size and then using the h/w ratio to see if I want to fill the screen in width or height.
Upvotes: 2