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
Highlighted
Developer
Posts: 49
Registered: ‎06-02-2009
My Device: Curve8530, Curve8900, Storm9500
My Carrier: Airtel, vodaphone, Wifi

Re: BrowserField (field2) image scaling

if you can not modify the html then scale the content after documentLoaded

 

_bf2 = new BrowserField(config);
_bf2.addListener(new MyBrowserFieldListener());


   class MyBrowserFieldListener extends BrowserFieldListener{

            public void documentLoaded(BrowserField browserField, Document     document) throws Exception {
                super.documentLoaded(browserField, document);

                      try{
                         int cw = _bf2.getContentWidth();

                         int sw = display.getWidth();
                         System.out.println("loaded content width  = " + cw);
                        
                         // scaling
                         if(cw > sw){
                             float scalFactor = ((float)sw)/cw;
                             _bf2.setZoomScale(scalFactor);
                             _bf2.invalidate();
                             doPaint();
                             invalidate();
                         }
                     }catch(Exception e){

                            System.out.println("Error in scaling", e);
                     }                       

 

The solution work perfectly for me.