Android Question HorizontalScrollView need end scroll event

Discussion in 'Android Questions' started by luciano deri, Jan 8, 2015.

  1. luciano deri

    luciano deri Active Member Licensed User

    Code:
    Sub PScreen_Touch (Action As Int, x As Float, y As Float)
        
    Select Action
            
    Case Activity.ACTION_DOWN
                startscroll = 
    True
        
    Case Activity.ACTION_UP 'only when make clik
                startscroll = false
         
    Case 3 'start scroll ?
                 .....
       
    End Select
       
    End Sub
    Hello everybody. I use HorizontalScroolView for show some page my program, i would like center the page on the screen every times that the user scroll over 50%x, but i dont' know how intercept event when scroll finish.
    Thanks. I thinked test the action panel_touch of panel on HorizontalScroolView, but haven't a end_scroll action.
     
    Last edited: Jan 8, 2015
  2. Erel

    Erel Administrator Staff Member Licensed User

    You should handle the ScrollChanged event.
     
  3. luciano deri

    luciano deri Active Member Licensed User

    This event is active every move on scroll, i need intercept when this move is finished and correct the position for centered the panel on screen.
     
    Last edited: Jan 12, 2015
  4. Erel

    Erel Administrator Staff Member Licensed User

    You can use a timer to find when the scroll finishes. Disable and enable a timer inside the event.
     
  5. klaus

    klaus Expert Licensed User

    You could try the attached project.
    It does what you want.
    It is based on Erels suggestion.
    I have added the Touch event for the HorizontalScrollView, there I :
    - calculate the approximate time needed to finish the scrolling
    - enable a timer with the calculated time
    In the Timer_Tick routine I check the ScrollPosition and according to its value set the final position.
    I use this method in the ClsWheels Class.
     

    Attached Files:

    Last edited: Mar 5, 2019
  6. luciano deri

    luciano deri Active Member Licensed User

    Thank you very much.
     
  7. Luiz Fernando Orlandini

    Luiz Fernando Orlandini Active Member Licensed User


    Cool I need something like that, but for B4i. What can I use instead of Reflector?
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    It is possible to implement a similar solution with the ScrollChanged event and a timer (start a new thread in B4i forum if you need more assistance).
     
  9. klaus

    klaus Expert Licensed User

    As a first step set the ScrollView.PagingEnabled property to True.
     
  10. Luiz Fernando Orlandini

    Luiz Fernando Orlandini Active Member Licensed User

    Yes Erel. I need some help.
     
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