Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Get Scrollview contentHeight

Dear People,

I was wondering if it's possible to get the value of the dynamic filled scrollview (im filling it with a webview and a imageview).

I'm setting the contentHeight to 'auto' and when i'm trying to get the actual size of the contentHeight it still gives me 'auto'.

Is there a solution?

— asked February 5th 2012 by Erik Giezen
  • actual size
  • contentheight
  • dynamic
  • scrollview
  • size
0 Comments

3 Answers

  • did you try leaving the contentHeight property empty?
    a Workaround could be using the scroll Event and check if it gives the right height.

    — answered February 5th 2012 by Alexander Bauer
    permalink
    0 Comments
  • If you want the height:
    scroll.getSize().height;

    If you want the contentHeight:

    var cnt = scroll.children.length;
    var lastChild = scroll.children[cnt-1];
    var cHeight = (lastChild.center.y + (lastChild.getSize().height / 2)) - scroll.getSize().height;
    
    — answered February 6th 2012 by Allen Hartwig
    permalink
    1 Comment
    • Oops, remove - scroll.getSize().height from my contentHeight example.

      — commented February 6th 2012 by Allen Hartwig
  • People i fixed it by detecting the height of the webview whitin it!

        myTimer = setInterval(function () 
        {
            actualHeight = text.evalJS("document.height;");        
    
            if(actualHeight > 10)
            {
    
            }
        },100);
    
    — answered February 9th 2012 by Erik Giezen
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.