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
Posts: 813
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later

adding image over image

http://s10.postimage.org/nnq1nqxdz/Untitled.png

 

If u see that image, i have the normal image. I want at the bottom of that image to add  that green play button, plus the names nancy ajram  dania helwa...

 

on click of green button, i will play music. on click of image i will take him to different screen. any helps?

 

HorizontalFieldManager hManagers = new HorizontalFieldManager(NO_VERTICAL_SCROLL | NO_VERTICAL_SCROLLBAR | NO_HORIZONTAL_SCROLL  | NO_HORIZONTAL_SCROLLBAR);

...........

EncodedImage image = EncodedImage.createEncodedImage(temp.albumCover,
                                 0, temp.albumCover.length);  
                          image = MAMClient.sizeImage(image, 300, 250);
                            // EncodedImage image = EncodedImage.getEncodedImageResource(directoryItem.getImageName());
                            hManagers.add(new BitmapField(image.getBitmap(),Field.FIELD_HCENTER
                                     | Field.FIELD_VCENTER | Field.FOCUSABLE)
                             {
                                
                                 protected boolean navigationClick(int status, int time)
                                 {     
                                    /* UiApplication app = (UiApplication) UiApplication.getUiApplication();
                                     GlobalValue.setCatId(directoryItem.getId());
                                     app.pushScreen(new TabControl(directoryItem.getId()));*/
                                   return true;
                                  }
                             });

 

Developer
Posts: 17,012
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: adding image over image

if you don't want the button to be focusable on its own i think the easiest way would be to use a graphics object to draw the whole thing.
create a bitmap of the appropriate size and use http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/ui/Graphics.html#create(net.ri... to get it's graphics object, then use graphics.drawBitmap for your images, drawText for the text.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Trusted Contributor
Posts: 151
Registered: ‎06-17-2010
My Device: Curve 8900
My Carrier: Vodafone

Re: adding image over image

hi babakar,

 

you can follow this link.

 

http://supportforums.blackberry.com/t5/Java-Development/Blending-Image-does-not-display-in-Torch-sim...

 

Thanks,

Albert Anks

----------------------------------------------------------------------------------------------------------------------------

feel free to press the like button on the right side to thank the user that helped you.


please mark posts as solved if you found a solution.

Developer
Posts: 813
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later

Re: adding image over image

here is solution

 

 public   Bitmap getOverlappedBitmap(Bitmap map, Bitmap icon) {
            Graphics g = new Graphics(map);
            int width = icon.getWidth();
            int height = icon.getHeight();
            int x = (map.getWidth() - width) / 2;
            int y = (map.getHeight() - height);
            g.drawBitmap(0, y, width, height, icon, 0, 0);
            return map;
        }

 

EncodedImage image = EncodedImage.createEncodedImage(temp.albumCover,
                                 0, temp.albumCover.length);  
                          image = MAMClient.sizeImage(image, 300, 220);
                         
                         Bitmap mMapBitmap = image.getBitmap();
                         Bitmap mIconBitmap = Bitmap.getBitmapResource("play.png");

                        hManagers.add(new BitmapField(getOverlappedBitmap(mMapBitmap, mIconBitmap),Field.FIELD_HCENTER
                                                  | Field.FIELD_VCENTER | Field.FOCUSABLE)

 

 

 

 

 

but problem is, how can i detect clicking on any of the 2 pics?

Highlighted
Developer
Posts: 152
Registered: ‎07-28-2011
My Device: Bold 9900
My Carrier: MTN

Re: adding image over image

Instead of using a BitmapField, you can create a bitmap button field that extends button field and you override the paint method to paint the image as the button.