Android Question Get scrolled/current position of panel in scrollview

Discussion in 'Android Questions' started by bitben, Mar 31, 2015.

  1. bitben

    bitben Member Licensed User

    hi,

    i have an scrollview element filled with a few panels. from every panel, when clicked, i want to start an animation, so i need the top position of every panel. as far as good, get it over the touch event. but when i scroll down and click on a panel, which was further down, the animation starts not on the current position, it starts on the "initialized" position. so my question is how i get current position from a clicked panel wherever the scrollposition is? sorry for my english, i hope you understand :)
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    bitben likes this.
  3. bitben

    bitben Member Licensed User

    This seems to be a solution, i'll try it on weekend and give a feedback
    sorry for my late answer
     
  4. bitben

    bitben Member Licensed User

    Ok i implemented your CustomListView, but i can't figure out how to get the position of every item.
    Here is a snippet, a panel (Panel2) should appear over an selected item and move away, but the panel appears always on top of the CustomView, maybe i am blind, what is my fault?
    I use panel.top and this only brings 0, what should i use?

    Code:
    Sub deviceList_ItemClick (Index As Int, Value As Object)
        
    Dim p As Panel = CustomView1.GetPanel(Index)
        
    Dim lbl1 As Label = p.GetView(0)
        
    Dim lbl2 As Label = p.GetView(1)
        a1.InitializeAlpha(
    "animate"10)
        a1.Duration=
    500
        [...]
        appear = 
    Array As Animation(a1)
        Panel2.Left = CustomView1.AsView.Left
        Panel2.Top = p.Top 
    '<- ?
        [...]
        Panel2.Visible = 
    True
        
    For i = 0 To appear.Length - 1
            appear(i).start(Panel2)
        
    Next
    End Sub
     
  5. RandomCoder

    RandomCoder Well-Known Member Licensed User

    Add this subroutine to the CustomListView Class and call it instead of calling GetPanel.....
    Code:
    'Returns the top position of the Panel stored at the specified index.
    Public Sub GetPanelPosition(Index As Int) As Int
        
    Dim top As Int
        
    Dim p As Panel
        
    For i = 0 To Min(Index - 1, items.Size - 1)
            p = panels.Get(i)
            top = top + p.Height + dividerHeight
        
    Next
        top = top - sv.ScrollPosition
        
    Return top
    End Sub
     
    bitben likes this.
  6. bitben

    bitben Member Licensed User

    Great, it works! Thanks
    I thought there is a given property i overlooked :D
     
Loading...
  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