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
New Contributor
Posts: 5
Registered: ‎07-11-2011
My Device: BlackBerry
My Carrier: Developer
Accepted Solution

Is it possible to make the browser field to fit to the actual size of the device screen?

I'm using browser field2 to load the content of a URL inside the application. The data gets loaded successfully.

 

But my requirement is to shrink the data and display that in such a way that without any scrolling the entire content should be visible in the device screen.


In the config, I've set the property - config.setProperty(BrowserFieldConfig.INITIAL_SCALE, new Float(0.1)); But still nothing works.

 

I want to do this in a way that irrespective of the BB device resolution/OS, the content of the URL should fit to the device screen.

 

Any help would be much appreciated. Thanks in advance..!!

Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Is it possible to make the browser field to fit to the actual size of the device screen?

Which development environment (SDK) are you using? I'm not sure you posted this in the correct forum. (If that's true, you can ask a moderator to move it by using the "Report Inappropriate Content" link to the left of your post.)

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Is it possible to make the browser field to fit to the actual size of the device screen?

Definitely a Java question, let us get this moved....

 

What you are asking is actually a little tricky.  The BrowserField will normally lay itself out and then the Java Screen will allow the user to scroll the extent that the page requires.  Since you do not actually know how much space the Field will require until this happens, you can not really pre-set the scaling.  So I think to do this properly will require you to display the BrowserField, then in the layout processing, determine that Field's size, then set the scale required, which will of course mean that the layout processing will get called again, so you will need to be careful you don't go round an infinite loop. 

 

A potentially easier alternative might be to send your URL request with the page size of the device, and the Server can use this to determine how it wants the page laid out.  That will mean it can work out landscape/portrait format differences and so on, which might cause issues if you attempt to scale or rework on the device with no knowledge of the content.

 

I am sure you will get other answers on the Java forum when this is moved. 

New Contributor
Posts: 5
Registered: ‎07-11-2011
My Device: BlackBerry
My Carrier: Developer

Re: Is it possible to make the browser field to fit to the actual size of the device screen?

Thanks Peter.... Smiley Happy  Let me try out what you've said. I'm waiting for other answers also just to know whether there's any work around for this.

New Contributor
Posts: 5
Registered: ‎07-11-2011
My Device: BlackBerry
My Carrier: Developer

Re: Is it possible to make the browser field to fit to the actual size of the device screen?

In the HTML of the web page add the meta tag with the minimum scale set to 0 

<meta name="viewport"

content="maximum-scale=10.0, minimum-scale=0, user-scalable=yes">

 

From the client side, we can shrink the web page using the initial scale method.

config.setProperty(BrowserFieldConfig.INITIAL_SCALE, new Float(value));

 

In my case, this meta tag was not there and so the initial scale option was not working after a certain limit. By this being set in the html, we can scale it to any value between the minimum/maximum defined scales. 

With this, my problem was solved.

But, if you want to fit it to the device screen, you'll have to calculate the scale value to make it set to the screen size in all the devices irrespective of the resolutions.