android - Scroll to a specific view in scroll view -


i have added scrollview , subchilds inside scrollview. @ point need scroll specific view.

<scrollview>  1. <linearlayout>      <textview></textview>     <textview></textview>     </linearlayout>  2. <linearlayout>      <textview></textview>     <textview></textview>     </linearlayout>  3. <linearlayout>      <textview></textview>     <textview></textview>     </linearlayout>  4. <linearlayout>      <textview></textview>     <textview></textview>     </linearlayout>  5. <linearlayout>      <textview></textview>     <textview></textview>     </linearlayout>  6. <linearlayout>      <textview></textview>     <textview></textview>     </linearlayout>  7. <linearlayout>      <textview></textview>     <textview></textview>     </linearlayout>     <button>    </button>   </scrollview> 

the above layout created dynamically. can't have xml file posted here. layout creation dynamic. number of child view inside linearlayout may vary.

so when click on button need scrolled particular view here when click on button need scroll linear layout 4. tried scrollto method scrolls top of scrollview.

please provide suggestions.

this should trick:

view targetview = findviewbyid(r.id.desired_view_id);   targetview.getparent().requestchildfocus(targetview,targetview); 

public void requestchildfocus (view child, view focused)

child - child of viewparent wants focus. view contain focused view. not view has focus.

focused - view descendant of child has focus


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -