Insert Form with gauge in Canvas J2ME

北城余情 提交于 2019-12-11 10:45:48

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/12311965/insert-form-with-gauge-in-canvas-j2me

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!