Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
hhessel
Posts: 33
Registered: ‎04-25-2009
My Device: Not Specified

Animated GIF Field loses Alignment

I used the KB Article How To - Display an animated GIF to display a loading GIF. It works but the after the first frame the Field isn't rendert in the correct position.

 

So

loader_mgr.add(new AnimatedGIFField(_loader, DrawStyle.HCENTER));

 

leads to

 

 

 

Any Ideas how to handle this?! Thanks!

 

New Contributor
apeiron0
Posts: 3
Registered: ‎12-03-2012
My Device: BOLD 4 Verizon 9930

Re: Animated GIF Field loses Alignment

In the AnimatedGifField class, check this:

public AnimatedGIFField(GIFEncodedImage image)
{
this(image, Field.FIELD_HCENTER);
}

It's there where you have to write the parameter HCENTER.
Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Animated GIF Field loses Alignment

Can't see the image, can you put it somewhere public and link to it?

 

I have had issues with some animated gifs where the image that was drawn was in the same place, but the 'movement' parts were not drawn correctly.  So it did not loose positional alignment - the image was just not correct.    Since I can't see the image I can only guess you are seeing something similar.  Try a few animated GIFs, including the one supplied, to see if the result is GIF specific. 

 

I don't think it is possible for an animated GIF Field to move its position while playing, so I don't think changing the Style will help here. 

 

New Contributor
apeiron0
Posts: 3
Registered: ‎12-03-2012
My Device: BOLD 4 Verizon 9930

Re: Animated GIF Field loses Alignment

I had the same problem and I could solve it changing the parametter inside of the above class. 

 

In the vertical field manager or screen class you can write:

 

GIFEncodedImage myGIFImage =(GIFEncodedImage)GIFEncodedImage.getEncodedImageResource("your_image.bin");
AnimatedGIFField image_field = new AnimatedGIFField(myGIFImage);
image_field.setMargin(62, 0, 0, 0);
add(image_field);

 

The 62 number is my custom top position.

 

In the  AnimatedGIFField class constructor below, you really need to make the change as...

 

public AnimatedGIFField(GIFEncodedImage image)
{
      this(image, Field.FIELD_HCENTER);
}

 

Remember that your image file cannot be in .gif type, because it wil be converted to .png type by the system.

 

I solved the problem... 

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Animated GIF Field loses Alignment

As noted, I think you solved a different problem.  I don't think it is possible for the animated gif to move postion while playing.  If it moves, it is something external (like a scroll), nothing to do with the Style, or the margin.  But that is just my opinion. 

New Contributor
apeiron0
Posts: 3
Registered: ‎12-03-2012
My Device: BOLD 4 Verizon 9930

Re: Animated GIF Field loses Alignment

We are not moving the animated gif while playing, we are changing the default position on the AnimatedGIFField class. The class that make possible playing the gif.

Sorry!