开发者

How to suspend gif animation when the Button is deactivated and how to align center vertically the gif relative to a LWUIT Button?

开发者 https://www.devze.com 2023-04-08 06:53 出处:网络
I put animated gif into the Resource Editor. I created a Button based on this gif Image , and the Button has also a text :

I put animated gif into the Resource Editor. I created a Button based on this gif Image , and the Button has also a text :

r = Resources.open("/resources.res");
uploadImg = r.getImage("upload");
envoieBtn = new Button("Envoyer", uploadImg);
envoieBtn.setTextPosition(Label.BOTTOM);
envoieBtn.setAlignment(Label.CENTER);

This Button is put in the main screen , and this Button is not enabled until the phone mobile database ( RecordStore ) is populated via the third Button ( second line first column in the captured i开发者_JAVA技巧mage ) on the main screen.

My problem is that even if the envoieBtn Button is disabled then the gif Image on it is animated ( the red arrow is still moving upward ) ! So how to suspend the animation of the gif image ?

My second question is how to center the image within the Button because on the captured image we see that the gif is not centered like the Button text.

Here is the captured image :

How to suspend gif animation when the Button is deactivated and how to align center vertically the gif relative to a LWUIT Button?


You can suspend animation by overriding animate in the button and avoiding the call to super, just always return false. The GIF will no longer animate (you can do that conditionally for disabled buttons).

Since alignment is determined by content you can't align a button with an image to one without an image since the location of the text is determined by the image. I suggest you create a transparent image object of the exact same size and assign it to the buttons that don't have an image on them.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号