| Reply | « Previous Thread | Next Thread » |
|
I have my app load text from a server. A lot of times the text gets fairly long, and to fit it better on the screen, I would like to decrease font size.
It seems that MIDP 1.0 (and I DO want to stick to 1.0) does not offer any way to change font for TextBox, TextField, nor StringItem. Canvas does have the option of specifying font however. My problem is such. When I use drawString with Canvas, the text does not wrap and I only get one line of text. Since text is generated dynamically, I have no way to insert line breaks in the text itself. Is there a way to wrap the text using drawString? Thank you. |
|
You have to implement the wrapping yourself. Lucky for you someone already did most of the work.
shmoove |
|
Thank you. Frankly, since MIDP 1.0 does not support setFont method for any Screens, I would just leave this alone (it's only a minor drawback). But recently I have come across an MIDP 1.0 application, which successfully displays dynamic text in various sizes. Now I can't let it go - gotta know ;)
I came to thinking that this application was using Canvas to draw text, but I don't think that Canvas is scrollable. In this application, that I am referring to, one can scroll text - not line by line but in "chunks" equal to display size. Any ideas how this has been achieved? |
|
When you get the "big" string you can split it into an array (or Vector, or whatever) of smaller strings, each of the smaller strings can fit in one line (using the WordWrap function). Then you need a variable to tell you what "page" you're currently viewing, and you calculate how many lines fit in one "page". Then you just need to draw the appropiate strings from your collection (the ones that go in the current page).
shmoove |
|
I will try that. Thanks a lot!
|
|
Quote:
Seems this link is no longer working, can you post this code in another place and send us the new link? Thank you |
|
|
| grahamhughes |
| View Public Profile |
| Find all posts by grahamhughes |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|