Android Question Need scrolling panel

Discussion in 'Android Questions' started by Scotter, Apr 22, 2019.

  1. Scotter

    Scotter Active Member Licensed User

    Hi -
    I see the "scrollview" view.
    My issue: It appears you can't set this up in the designer to hold other views.
    I see after a search that it can be done programmatically.
    However, I really need the ability to set it up in the designer.
    Should I give up or is there a custom component available that does this?
  2. JohnC

    JohnC Well-Known Member Licensed User

    Scotter likes this.
  3. DonManfred

    DonManfred Expert Licensed User

    You should use xCustomListview. xCustomListview = Scrollview plus additional features.
    Scotter likes this.
  4. Jeffrey Cameron

    Jeffrey Cameron Well-Known Member Licensed User

    I generally setup my "inner panel" in the designer as its own layout, then at runtime load the layout into the scrollview's panel directly or a containing panel if multiple "rows" need be displayed.
    Scotter likes this.
  5. JohnC

    JohnC Well-Known Member Licensed User

    There are work-arounds/alternatives, but they typically require programmically designing/adding the contents of a scroll view.

    But my desire (and I think Scotter's desire too) is that there are many instances in which it would be just so convenient to be able to simply place views within a scrollview using the "designer" just like we can easily add views to a panel.

    We all know it is possible to add views and position them in a layout programmically, but the whole reason for adding a visual designer to the IDE is to make that process easier. And it would just be so much easier to be able to place views within a scroll view without the need to programmically do anything.
    Last edited: Apr 22, 2019
    Scotter likes this.
  6. Jeffrey Cameron

    Jeffrey Cameron Well-Known Member Licensed User

    As I said in my post, you create your inner layout in the designer visually as desired. The only part missing from your request is that you cannot see the truncated result inside the scrollview container in your main layout. And the only line of code required programmatically is the "Scrollview1.Panel.LoadLayout("InnerPanel")" right after your initial Activity.Loadlayout("MainPanel").
    Scotter likes this.
  7. klaus

    klaus Expert Licensed User

    You need to distinct two objects:
    1. ScrollView, which is a vertical scrollview you can add in the Deisigner. You cannot add any views directly on it in the Designer.
    The height of the ScrollView must not be heigher than the screen, otherwise not all the content will be displayed.
    2. ScrollView.Panel, which is the internal Panel of the ScrollView. You can load onto this Panel any layout like in any 'standard' Panel.
    The height of this Panel can be any value and of course heigher the the screen height.
    But you need to set this height with ScrollView.Panel.Height = xx.

    You may have a look this example: ScrollView example with a Panel higher than the screen.
    You can, of course, also use xCustomListView which is a much more versatile view based on a ScrollView.
    Erel and Scotter like this.
  8. JohnC

    JohnC Well-Known Member Licensed User

    I understand all that, and that's what I currently do.

    But, I was simply expressing my desire to have Scrollview be a no-brainer to work with without having to:

    1) Create a scrollview in a separate layout
    2) Create another layout and place views in it
    3) Load the first layout, then the second layout, then set the first layouts inner-panel to the height of the second layout

    It would just be cool to simply have one layout that I place a scrollview on, then add views inside it. Then simply load the one layout and like magic it will scroll its contents automatically based on the screen size.
    Scotter likes this.
  9. Scotter

    Scotter Active Member Licensed User

    Thank you!!! That IS what I was looking for!
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice