Search code examples
androidpopoverandroid-scrollview

Multi-View Android ScrollView scrollTo Popover not working


My app opens up in View A. In View B, I have made a custom popover who's view contains:

LinearLayout
    ScrollView
        LinearLayout1
        LinearLayout2
              .
              .
              .
        LinearLayoutN

What I wish to do is From View A, Move Into View B having set the Vertical Scroll position to a specific LinearLayout from the ScrollView within the Popup.

I have the scrollview being assigned in code to a variable and

variable.scrollTo

is NOT working.

I have also tried to put

sView.post(new Runnable() {     
    @Override     
    public void run() {         
        sView.scrollTo(0, myNum);     
    }  
});

within the routine I run to setup View B, Tried it Outside in the OnCreate routine. Nothing seems to be working to scroll the ScrollView.


Solution

  • The

    sView.post(new Runnable() {     
        @Override     
        public void run() {         
            sView.scrollTo(0, scrollYPos);     
        }  
    });
    

    was EXTREMELY useful, however its placement was even more important. Do to the scrollview being inside of a popover view, the code above actually had to be placed AFTER the code that truly brought that popover onto screen.