Android Question Keep scrollview position to rotate the screen

Discussion in 'Android Questions' started by rscheel, Dec 30, 2015.

  1. rscheel

    rscheel Well-Known Member Licensed User

    Hi, I need to maintain the position of scrollview to rotate the screen.

    I've searched the forum but found nothing concrete.

    Thanks for your time.

    I tested receive the scroll with this position but I do not get anything, only 0

    Code:
    Sub ScrollView1_ScrollChanged(Position As Int)
       
    End Sub
     
  2. klaus

    klaus Expert Licensed User

    You have the ScrollView1.ScrollPosition property.
    You can get and set it.
     
  3. rscheel

    rscheel Well-Known Member Licensed User

    It would be something like the following code, the truth does not work for me, you miss me something, or am doing wrong.

    Code:
    Sub Process_Globals
        
    Dim PosicionScroll As Int
    End Sub

    Sub Globals
        
    Private ScrollView1 As ScrollView
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
        
    Activity.LoadLayout("LayoutMain")
        ScrollView1.Initialize(
    700dip)
        pContent.AddView(ScrollView1,
    0,0,100%x,100%y)
        ScrollView1.Panel.LoadLayout(
    "LayoutCont")
    End Sub

    Sub ScrollView1_ScrollChanged(Position As Int)
        PosicionScroll = Position
    End Sub

    Sub Activity_Resume
        ScrollView1.ScrollPosition = PosicionScroll
    End Sub
     
  4. klaus

    klaus Expert Licensed User

    I would use:
    Code:
    Sub Activity_Pause
        PosicionScroll = ScrollView1.ScrollPosition
    End Sub
    Instead of setting PosicionScroll in ScrollView1_ScrollChanged.
     
    Erel likes this.
  5. rscheel

    rscheel Well-Known Member Licensed User

    Thanks for your help, but I did not work, followed reciviendo 0 that position.
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    You can use StateManager. It stores the position.
     
    rscheel likes this.
  7. rscheel

    rscheel Well-Known Member Licensed User

    Thank works perfect.
     
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