Android Question layout in scrollview panel is scaled, why?

MarcRB

Active Member
Licensed User
Longtime User
Hi,

I have a layout with some basic views and one special view: Horizontal scrollview
The inner panel of the scrollview is loaded with a second layout.

B4X:
Scrollitem.Panel.Width =1700dip
Scrollitem.Panel.height = 380dip
Scrollitem.FullScroll(True)
Scrollitem.Panel.LoadLayout("panItem")

The second layout (the one in the inner panel of the scrollview) is also filled with basic views.
because of the width 1700dip it must be horizontal scrollable.
I see some strange behaviour:

  1. The layout is created at 1700 x 380 scale 1
    But in the designer, I can see that a view placed from top to bottom has a height of 280.
    Why is the original height not respected?

  2. If the inner panel is loaded with this layout, the layout is smaller sized as expected.
    I think it is about 30% smaller in both sides. Why is it scaled smaller ?
Device: Asus Memopad HD 7" tablet, with 1280 x 800 screen 215.63 pixel density

Best regards,
Marc
 

MarcRB

Active Member
Licensed User
Longtime User
Erel,

This little project + screenshot shows the issue.
I Hope you have a solution. Thanks in advance.

Marc


Text in bottom label 1700 x 380 must be 1700 x 330 !
 

Attachments

  • test_scroll_layout.zip
    422 KB · Views: 126
Upvote 0

MarcRB

Active Member
Licensed User
Longtime User
Hi Klaus,

Playing with AutoScale in the designer script (on or off) did make a little change in size but it is still not the size as set.

and can you explain what you mean by:
Or set the width in the code according the view positions.
 
Upvote 0

MarcRB

Active Member
Licensed User
Longtime User
Klaus post was creating a new idea.

Ok.. I found something. I have it working on my tablet. I'm afraid this is now only working for this resoluiton and dpi.
But I still do not understand why excatly the scaling happens.

I found the main window is also scaled but this layout is scaled bigger.
In designer the scrollview has a height of 330. But on runtime the same scrollview is changed in height to 439.
If I change the size of the innerpanel by code to 439 too and in the designer I change the layout size also to a height of 439, than it works.

But i don't understand why the scrollview is placed at size 330 and after runtime it is 439. it is a scalefactor 1.33
So i think it has something to do width the original scale of my device.
 
Upvote 0

MarcRB

Active Member
Licensed User
Longtime User
The height of the inner panel in the case of horizontal scroll view is maintained by the scroll view. It fills the available space. You cannot modify it.

Because English is not my best languague I think I didn't describe it good enough.But it is solved.

I don't want to modify the inner panel height. I just need a layout with the same height for loading into the inner panel.
And I made it the same height. But it looks wierd. The layout inside the scrollview is smaller. Why?
Now i Know it:
It was not the layout inside being smaller. No!, the main layout was bigger! All views (including the scrollview) where bigger. +1.33x bigger. Because the layout loaded into the scrollview was not enlarged, it looks small according to the outside views on the main layout.

Now the new issue was, why is the main layout bigger as defined. I entered a value of 330 for the scrollview outside height.
On the tabletscreen it was placed at 439pixels. Infact every view was 1.33x bigger on runtime.
That is because the tablet has 1280x736 pixels screen and the layout was set to 960 x 552 scale 1.0 (according factor 1.33)
Ok... Why was the layout set to a variant of 960x552? That is because this seems to be the equivalent value with scale 1 for my tabletthat has standaard a 1.33125 scale.

Creating a new variant with the original dimensions 1280 x 736 at scale 1.33125 solved the problem. I only had to ignore the warning about normalizing the scale to 1.0. At least in this case: It is now working without any other change in code or design.

Thanks for your help, Klaus and Erel.

Best regards,
Marc
 
Upvote 0
Top