Scrollviews with dynamic vbox

Hi again !

I have a little problem with scrollviews. :slight_smile:

I have a scrollview that contains page view which is create dynamically by adding some images text areas and vboxes inside it.

When I do this

<scrollview  height="20%" width="100%" contentWidth="100%" >
         <vbox id="pageView" width="90%" horizontalAlign="center" autoHeight="true">
     </scrollview>

I have

When I put height="5000 , I have a scroll view :slight_smile: But as my page page is created dynamically, but obviously 5000 is too long/short

<scrollview  height="20%" width="100%" contentWidth="100%" >
        <vbox id="pageView" width="90%" horizontalAlign="center" height="5000"
>
    </scrollview>

I have tried putting some trace into scrollview to understand why, the scroll don’t appear in the first case, it seems it considers the height of the vbox or 10 or 0.

`

Hey :slight_smile:

What is in the vbox? The autosize basically means “size to its content” and in that xml, it doesnt look like there is anything in vbox?

I have a scrollview that contains page view which is create dynamically by adding some images text areas and vboxes inside it.

Hmmm, so it does have contents… can you give an example of these contents? Feels like a bug… but i dont quite understand why it would be…

does style="height:auto" on the vbox make any difference?

Cheers,
Ian

EDIT: does the same happen outside of a scrollview? Ie, just a vbox with its contents added dynamically… i do it all the time… in fact… vbox should autosize by default anyway thinking about it.

Sorry to have bothered you ! ( again … )
It works. :slight_smile:

In fact I was showing some epubs .
I had some automatic styling from the epubs that was applied. One of them was percentHeight = “100%” , autoHeight = false;
I had actually thought about the problem ( but forgot about it … ), when I was still not using scrollviews, so I would change the style before applying it, I was setting only autoHeight to true, but the percentHeight was still 100%, so it caused some problem.Having autoHeight to false and having percentHeight to null , was also causing some problems. When it was in a normal VBox, everything was working correctly.

The solution
was just to set autoheight to true and percentHeight to null :slight_smile: ;

So, just to confirm, its all OK?

And also, the fix was:

myVBox.autoHeight = true;
myVBox.percentHeight = null;

If that is the case, i wonder if setting autoHeight should automatically set percentHeight to null… I tried something similar in applyStyle recently but it had… … weird side effects… maybe i should look a little deeper into it.

Yes it’s all OK :smiley: The fix was indeed this simple.>

If that is the case, i wonder if setting autoHeight should automatically set percentHeight to null…

I think it’s a good idea. I don’t see really a case where you should have both set.
Now, I don’t think many people will make the same mistake as me. I did this mistake because I was applying styles from some epubs, but if i had written the styles myself ( as with normal components), I would have noticed it a lot faster.

1 Like

I think it’s a good idea. I don’t see really a case where you should have both set.

Agreed

Well, glad its fixed - ill take a look at making it so you cant have both set…

Cheers,
Ian

1 Like