Author Topic: Set scrollview to specific width  (Read 2799 times)

kalledemos

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Set scrollview to specific width
« on: February 06, 2014, 10:21:41 PM »
Is there a way to set a scroll view to be a specific width?  I need it to fill a portion of the bottom of the screen regardless of the aspect ratio.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Set scrollview to specific width
« Reply #1 on: February 06, 2014, 10:37:10 PM »
Anchor the scroll view's panel, or just set its UIPanel.baseClipRegion

kalledemos

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Set scrollview to specific width
« Reply #2 on: February 07, 2014, 11:46:37 AM »
Anchoring it seems to work at the start, but when I try to move it at runtime its contents get off centered.

kalledemos

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Set scrollview to specific width
« Reply #3 on: February 07, 2014, 12:44:06 PM »
Ok I just used UIStretch.  It seems to work pretty well with UIAnchor to keep it at relative position and width.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Set scrollview to specific width
« Reply #4 on: February 08, 2014, 03:01:35 PM »
Don't use UIAnchor and UIStretch. All panels and widgets have "Anchors" section that you can use instead.

Unless you're on an older version of NGUI.

kalledemos

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Set scrollview to specific width
« Reply #5 on: February 09, 2014, 01:18:29 PM »
Do those anchors only run once at initialization, allowing them to be freely moved afterwards?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Set scrollview to specific width
« Reply #6 on: February 09, 2014, 04:47:07 PM »
New anchoring system is persistent. If something is anchored, you can't move it unless you remove the anchor. However tweens still work as expected even if the object is anchored.