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
Posts: 62
Registered: ‎10-29-2008
My Device: 9800
My Carrier: Rogers

Trying to use webview to display formatted HTML but having issues with height

So I am attempting to display some formatted HTML inside of a webview. This HTML will have some basic formatting, such as images and paragraph tags etc.

 

I would then like to add some content below this webview (buttons and such).

 

The issue is that the HTML will take up the entire height of the screen. This isn't a problem if I have content that is long, however if I have some short content it forces the buttons below the bottom of the "fold" as it were.

 

Does anyone know how I can get the height of the webview to work the way I want it to? Does this make sense?

Developer
Posts: 1,280
Registered: ‎03-03-2011
My Device: Playbook, Z10, Q10, Z30 with Files & Folders and Orbit of course
My Carrier: Vodafone

Re: Trying to use webview to display formatted HTML but having issues with height

One way might be to wait until the page is loaded, inject some javascript to calculate the height of the body and return that to Cascades using evaluateJavaScript(), then set the height and show the WebView.

Files & Folders, the unified file & cloud manager for PlayBook and BB10 with SkyDrive, SugarSync, Box, Dropbox, Google Drive, Google Docs. Free 3-day trial! - Jon Webb - Innovatology - Utrecht, Netherlands
Developer
Posts: 410
Registered: ‎06-03-2010
My Device: Z10 Red
My Carrier: Free

Re: Trying to use webview to display formatted HTML but having issues with height

I don't think you can have the height while the webview is not displayed.

 

According to this article: http://devblog.blackberry.com/2012/09/cascades-custom-ui/ , I also think that it does not make sense to work with real height dynamically.

 

 

Can't you fix the height of the webview once and for all, smaller that the screen, and allow it to scroll itself? The nodes on the bottom will always be visible.

New Contributor
Posts: 7
Registered: ‎10-22-2011
My Device: 9900, Playbook
My Carrier: starhub

Re: Trying to use webview to display formatted HTML but having issues with height

Hi,
I got same issue with WebView height. When the content is few line of texts, the height is same as device height ~ which was bad for what i plan on doing.
So i try adding this attribute on WebView:

- maxHeight: 300.0
- minHeight: 200.0
- preferredHeight: 210.0

and some how it looks just fine now Smiley Very Happy , it shrink just fine now, although i'm not really sure if the content is so long.

note: i'm new in cascade, so i'm not really sure if this is the correct way of doing this.

I hope this also works for you @rnickel

 

Btw, is there anyway for Label ( or maybe different control ) - apart from WebView - that support html formatting ?

something like TextView in Android that can handle html formatting by passing Html.fromHtml( "html" )

 

Thank you

Developer
Posts: 51
Registered: ‎11-23-2012
My Device: BB10 Dev Alpha
My Carrier: GiffGaff

Re: Trying to use webview to display formatted HTML but having issues with height

>> Btw, is there anyway for Label ( or maybe different control ) - apart from WebView - that support html formatting ?

something like TextView in Android that can handle html formatting by passing Html.fromHtml( "html" )

 

Yes, basic HTML styling is supported in Labels and you can set them to be multiline.  Scroll down to the second half of this page to find the HTML styling docs:

https://developer.blackberry.com/cascades/documentation/ui/text/styles.html

New Contributor
Posts: 7
Registered: ‎10-22-2011
My Device: 9900, Playbook
My Carrier: starhub

Re: Trying to use webview to display formatted HTML but having issues with height

Thank's Smiley Happy, haven't read the whole documentation, but so far it's quite fun developing in bb10