Author Topic: Scrollview and Grid issue - empty space at top and bottom  (Read 4835 times)

Jeffo

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 8
    • View Profile
Scrollview and Grid issue - empty space at top and bottom
« on: December 15, 2014, 05:41:17 PM »
Hello again!

I've been having an issue with scrollviews and grids for some time when creating a dynamic content list for the grid. There seems to be an added space at the top and the bottom of the grid and the scrollview will scroll to it, not clamping properly contents.

Examining the examples compared to mine, the only difference I've noticed is in your example the list is manually added and placed.

Screen 1 - this is how the list defaults


Screen 2 - shows that the contents will scroll up to the panel size, however it will allow the user to continuing scrolling showing an empty space at the bottom similar to the space in the above screen


Notes:
- I do manually reposition the grid and reset scrollview position after populating the list, which again defaults to screen 1 results.
- One thing that looks odd to me is the size of the grid (in the runtime looks larger than the panel its parented to), which Im not sure what would be controlling that other than cell width/height, which would skew my contents if adjusted.

Any insight would be much appreciated!

Thanks,
Jeff
« Last Edit: December 15, 2014, 05:53:30 PM by Jeffo »

Ferazel

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 150
    • View Profile
Re: Scrollview and Grid issue - empty space at top and bottom
« Reply #1 on: December 15, 2014, 06:02:37 PM »
Keep a reference to the scrollview and the layout view and then after populating the content perform the following.

gridReference.Reposition():
scrollReference.ResetPosition();

That should help reset the scrollview and grid view correctly.

Jeffo

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Scrollview and Grid issue - empty space at top and bottom
« Reply #2 on: December 15, 2014, 06:38:28 PM »
Thanks for the reply. I actually am doing that already and it resets to the Screen 1 above.

Ferazel

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 150
    • View Profile
Re: Scrollview and Grid issue - empty space at top and bottom
« Reply #3 on: December 15, 2014, 07:08:38 PM »
Whoops, sorry I missed that you said that. Could you show us the scene hierarchy when it's populated? The content border is definitely not being set correctly (as you can see by the orange box). I'm thinking that maybe it's factoring in some sort of drag area widget?

Jeffo

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Scrollview and Grid issue - empty space at top and bottom
« Reply #4 on: December 15, 2014, 08:45:51 PM »
Ah thanks for the suggestion. That helped me figure it out!

This was in a popup, and I use a manager that creates the popups and auto scales to res. The scaling of the popup is what messed it up. I needed to initialize at scale 1, then wait a frame and scale it to screen res to fix it.

Jeffo

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Scrollview and Grid issue - empty space at top and bottom
« Reply #5 on: December 15, 2014, 09:26:31 PM »
Update: That seemed to have fixed it for single groupings, however when switching between different gear tabs it gets messed up again, presumably since the popup has been autoscaled and is not at scale 1.

Hmmm.

Jeffo

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Scrollview and Grid issue - empty space at top and bottom
« Reply #6 on: December 15, 2014, 09:36:08 PM »
and I fixed that by popping the scale back to 1, then back down once the list was finalized.

Seems pretty hacky of a solution, am I missing something here?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scrollview and Grid issue - empty space at top and bottom
« Reply #7 on: December 17, 2014, 02:53:10 PM »
Well, my question is... Why is there scaling involved?

Jeffo

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Scrollview and Grid issue - empty space at top and bottom
« Reply #8 on: December 19, 2014, 03:11:28 PM »
I use scaling since it's a popup and I always want it to be the same size on the screen no matter the resolution of the device.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scrollview and Grid issue - empty space at top and bottom
« Reply #9 on: December 19, 2014, 06:21:20 PM »
So why not use a constrained UIRoot then? Same effect, your UI will stay the same size automatically.