1

I'm trying to display a website inside my blackberry app but the browserfield is smaller than the screen height and i can`t make it the same size.

The page that is beeing loaded is actually smaller then the screen but the website is designed for mobile devices and fits perfectly on iphone webview, blabkberry browser and firefox and chrome.

My code is the following:

    manager = new VerticalFieldManager(VerticalFieldManager.VERTICAL_SCROLL | VerticalFieldManager.HORIZONTAL_SCROLL)
    {
        protected void sublayout(int maxWidth, int maxHeight)
        {
            super.sublayout(maxWidth, maxHeight);
            setExtent(Display.getWidth(), Display.getHeight());
        }
    };
    manager.setBackground(BackgroundFactory.createSolidBackground(Color.RED));

    BrowserFieldConfig myBrowserFieldConfig = new BrowserFieldConfig();

    myBrowserFieldConfig.setProperty(BrowserFieldConfig.ALLOW_CS_XHR, Boolean.TRUE);
    myBrowserFieldConfig.setProperty(BrowserFieldConfig.JAVASCRIPT_ENABLED, Boolean.TRUE);
    myBrowserFieldConfig.setProperty(BrowserFieldConfig.INITIAL_SCALE, new Float(1));

    browserField = new BrowserField(myBrowserFieldConfig);
    browserField.requestContent(link);

    manager.add(browserField);

The effect that I get is the following: when i load this screen the hole screen is red (the manager background). After that the screen turns white (i think this is the browserfield) and then when the webpage is loaded the screen turns red again and the white piece shrinks to a line height and grows as the webpage ellements starts to show. The problem is that the page should fit all the screen as it does in iphone and custom browsers.

OBS: I'm using blackberry OS version 6

Tetsujin no Oni
  • 7,300
  • 2
  • 29
  • 46

5 Answers5

5

This code in html:
<meta name="viewport" content="width=device-width,height=device-height,minimum-scale=1, maximum-scale=1" />
can be replaced with this on client:

config = new BrowserFieldConfig();
  config.setProperty(BrowserFieldConfig.VIEWPORT_WIDTH, new Integer(
            Display.getWidth()));
    config.setProperty(BrowserFieldConfig.INITIAL_SCALE, new Float(1.0));

    config.setProperty(BrowserFieldConfig.USER_SCALABLE, Boolean.FALSE);

    browserField = new BrowserField(config);
Alessandro Minoccheri
  • 35,521
  • 22
  • 122
  • 171
wtrocki
  • 208
  • 3
  • 6
4

I don't know if my solution would help you but I faced exactly the same issue as yours,after spending hours on it I finally fixed it by adding the following line in the header section of my html page:

<meta name="viewport" content="width=device-width,height=device-height,minimum-scale=1, maximum-scale=1" />

Height=device-height fixed my issue

Ala' Alnajjar
  • 788
  • 1
  • 11
  • 23
  • Thank You sooooooooo much! Exactly what I needed. I had the viewport width and didn't even think about the height. Thank You again!!!! – yanike May 14 '14 at 03:01
1

Try like this:

protected void sublayout(int maxWidth, int maxHeight)
{
     super.sublayout(Display.getWidth(), Display.getHeight());
     setExtent(Display.getWidth(), Display.getHeight());
}
alishaik786
  • 3,696
  • 2
  • 17
  • 25
  • Thank you for you help but i've tryed that already that is not the solution. What I have here is a problem with the browserfield, the manager is working great since the hole screen is painted in red (red is the manager background) – Fernando Heck Dec 19 '11 at 12:03
0

try this

   class MyFieldManager extends VerticalFieldManager
    {

    int width;
    int height;

    MyFieldManager(int w,int h)

    {
        super(Manager.VERTICAL_SCROLL | Manager.HORIZONTAL_SCROLL );
        width=w;
        height=h;
    }

    public void    sublayout(int w,int h)
    {
        super.sublayout(w, h);
        setExtent(width,height);
    }
}

    BrowserFieldConfig config = new BrowserFieldConfig();  
    config.setProperty(BrowserFieldConfig.ALLOW_CS_XHR, Boolean.TRUE);  
    config.setProperty(BrowserFieldConfig.INITIAL_SCALE, new Float(0.5));
    MyFieldManager m=new MyFieldManager(Display.getWidth()/2,Display.getHeight()/2);
    add(m);
    BrowserField _browserField = new BrowserField(config);
    _browserField.addListener(new InnerBrowserListener());
    m.add(_browserField);
askquestion
  • 171
  • 1
  • 14
Pandiyan Muthu
  • 1,040
  • 4
  • 21
  • 39
0

try in sublayout passing Display.getHeight() instead f maxHeight

Tamar
  • 2,016
  • 1
  • 15
  • 26
  • Hi, thanks for you help but that I have already tryied that and that is not the solution. The way I described to problem I was trying to tell you that the problem is not in the manager, since the hole screen is RED (the manager background). – Fernando Heck Dec 19 '11 at 12:02