Blackberry BrowserField 不适合屏幕

发布于 2024-12-21 09:52:16 字数 1224 浏览 0 评论 0原文

我试图在我的黑莓应用程序中显示一个网站,但浏览器字段小于屏幕高度,我无法使其大小相同。

正在加载的页面实际上比屏幕小,但该网站是为移动设备设计的,非常适合 iPhone webview、blabkberry 浏览器以及 Firefox 和 Chrome。

我的代码如下:

    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);

我得到的效果如下:当我加载此屏幕时,孔屏幕为红色(管理器背景)。之后,屏幕变白(我认为这是浏览器字段),然后当加载网页时,屏幕再次变红,白色部分缩小到行高,并随着网页元素开始显示而变大。问题是页面应该适合所有屏幕,就像在 iPhone 和自定义浏览器中一样。

OBS:我使用的是黑莓操作系统版本 6

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

野生奥特曼 2024-12-28 09:52:16

html 中的代码:

可以在客户端替换为:

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);

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);
卷耳 2024-12-28 09:52:16

我不知道我的解决方案是否对您有帮助,但我遇到了与您完全相同的问题,在花了几个小时之后,我终于通过在 html 页面的标题部分添加以下行来修复它:

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

Height=device-heightfixed我的问题

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

盗心人 2024-12-28 09:52:16

尝试这样:

protected void sublayout(int maxWidth, int maxHeight)
{
     super.sublayout(Display.getWidth(), Display.getHeight());
     setExtent(Display.getWidth(), Display.getHeight());
}

Try like this:

protected void sublayout(int maxWidth, int maxHeight)
{
     super.sublayout(Display.getWidth(), Display.getHeight());
     setExtent(Display.getWidth(), Display.getHeight());
}
云柯 2024-12-28 09:52:16

尝试在子布局中传递 Display.getHeight() 而不是 f maxHeight

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

千仐 2024-12-28 09:52:16

试试这个

   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);

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文