android - How to programmatically scroll an HorizontalScrollView -


i have horizontalscrollview contains relativelayout. layout empty in xml, , populated java in oncreate.

i scroll view somewhere in middle of relativelayout, way larger screen.

i tried mhorizscrollview.scrollto(offsetx, 0); doesn't work. don't know what's wrong this.

i post code, not relevant. matters done programatically (has :s), , initial position of horizontalscrollview has set programmatically.

thanks reading. please tell me if need more details or if not clear enough.

i found if extend horizontalscrollview , override onlayout, can cleanly scroll, after super call onlayout:

myscrollview extends horizontalscrollview {     protected void onlayout (boolean changed, int l, int t, int r, int b) {         super.onlayout(changed, l, t, r, b);         this.scrollto(wherever, 0);     } } 

edit: scrolling start or end can use:

this.fullscroll(horizontalscrollview.focus_right/focus_left); 

instead of

this.scrollto(wherever, 0); 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -