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

Native Development

Reply
Developer
mdodd
Posts: 188
Registered: ‎07-19-2012
My Device: Z10 LE

Automatically adjusting WebView height

Hi,

I currently have a custom component that loads some html-formatted text from a JSON file and puts it into a WebView. As this text may contain an <img> tag, I cannot put it in a label. The problem I'm having is that the webview takes up the entire height of the screen, leaving a large amount of white space to scroll down through before reaching the next component.

 

Here is my QML:

Container {
    property alias heading: heading.text
    property alias content: content.html
    
    Label {
        id: heading
        objectName: "heading"
        
        textStyle {
            fontWeight: FontWeight.Bold
        }
    }
    
    WebView {
        id: content
        objectName: "content"
        
        
        horizontalAlignment: HorizontalAlignment.Fill
 	     
 	     settings {
 	         defaultFontSize: 16 
 	     }
 	     
    }
}

I can't use preferredHeight  or maxHeight as this will cause any text larger than the webview height to be cut off, and adding minHeight has no effect.

 

This is the expected result for the QML:

expected.png

 

 

And this is the actual result due to the automatic height of the webview:

result.png

 

Any help would be greatly appreciated. Thanks.

 



Did this post help you? If so, please make sure to "like" it!
Developer
fredoust
Posts: 75
Registered: ‎09-12-2012
My Device: Looking for a BB10 testing device

Re: Automatically adjusting WebView height

I got the same problem, did you solve it ?

May be a Cascades bug ?

---------
Mobile developer freelance - QtQuick - Cascades - WP7 - Android
My works : http://fdelgado.fr
Contributor
nico411
Posts: 34
Registered: ‎12-20-2010
My Device: DevAlpha Beta 2

Re: Automatically adjusting WebView height

Hello,

 

I have the same issue.

Somebody has managed to fix it ?

 

Thanks

New Contributor
ManicBlowfish
Posts: 3
Registered: ‎04-01-2013
My Device: Dev Alpha B

Re: Automatically adjusting WebView height

No news on this?

New Developer
MarkZhong
Posts: 12
Registered: ‎03-15-2013
My Device: simulator

Re: Automatically adjusting WebView height

just use layoutupdatehandler in the container