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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Developer
rakeshsoni
Posts: 46
Registered: ‎06-02-2009
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.

Please use plain text.