android - How to stop scroll ScrollView when show speicific view in ScrollView? -


how stop scroll scrollview when show speicific view in scrollview ?

         .....          view2 ---------------------------------- |                                | |        view3                   | |                                | |                                | |        view4                   | |                                | |                                | <------ it's screen  |        view5                   | |                                | |                                | |        view6                   | |                                | |                                | |        view7                   | |                                | |                                | |        view8                   | |                                | |                                | |        view9                   | ----------------------------------           view10          ...... 

how catch moment when view9 showed , stop scrolling.

i never had here do.

first, need detect when view9 diplayed , visible. use

rect scrollbounds = new rect(); scrollview.gethitrect(scrollbounds); if (imageview.getlocalvisiblerect(scrollbounds)) {     // imageview within visible window } else {     // imageview not within visible window }  

(from https://stackoverflow.com/a/12428208/3187128)

try execute every x second test code.

then, if want cleaner, should use scrolllistener:

scrollview.getviewtreeobserver().addonscrollchangedlistener(new onscrollchangedlistener() {      @override     public void onscrollchanged() {          int scrollx = rootscrollview.getscrollx(); //for horizontalscrollview         int scrolly = rootscrollview.getscrolly(); //for verticalscrollview         //do scroll coordinates      } }); 

(from https://stackoverflow.com/a/23365539/3187128)

last step implement custom scrollview able disable scrolling :

cf https://stackoverflow.com/a/5763815/3187128

hope :)


Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -