SoH
SoH

Reputation: 2190

Insert Form with gauge in Canvas J2ME

I want to know if it is possible to somehow show a gauge in a canvas? I want to make a custom alert with a spinner.

But I want to reduce the height of the form to let's say 1/4th of the screen size. Could anyone tell me if its possible?

Upvotes: 1

Views: 524

Answers (2)

gnat
gnat

Reputation: 6229

There is no way to get that with MIDP 2 API.

Form class simply has no methods allowing application developer to specify its size.

That's the way it generally is with high level MIDP UI objects like Form, Alert, Gauge etc. You write a little code and specify desired behavior in general and you get it, but "in exchange" MIDP allows device manufacturers to decide on lower level details (like Form size or Gauge looks) and display them any way they want.


Since you want the Gauge look like you've seen at particular Nokia device, you should better know that on some other device, this Gauge may look completely different. So can Alert and Form.

If you really want to guarantee such kind looks of UI elements on different devices, you would have to use Canvas and other kind of low level graphics API - but that would require a lot more coding and much more complicated application design, with threads, animation, proper scaling to device screen size etc etc. I would think twice before diving into that.

Upvotes: 0

funkybro
funkybro

Reputation: 8671

If you want something like a spinner in a Canvas you need to draw it yourself using graphics primitives, and animate using Display.callSerially().

Instead of drawing it yourself you could include each frame of the spinner as an image. You'd still need to animate them somehow. Or you could use animated GIFs if your device supports them.

Upvotes: 1

Related Questions