dmitry-zaitsev/AndroidSideMenu

Open SideMenu when perfect horizontal move

Closed this issue · 2 comments

First of all, thank you for sharing your work, who's awesome.
I have a listview with many elements, and i implemented your SideMenu.

I would like to open the side menu only when the user scroll horizontally (not diagonal move) the view. Actually the scrolling of listview is disrupting by the SideMenu who start open when the user do a vertical scroll...

I hope you can help me.

Thanx

Thanks for your report 👍

I understand your intention to open side menu only with strictly horizontal swipe, but current implementation was the desired behaviour when I started to work on this lib. Although, I think it can be exposed as additional option to SideMenu, so I'll add it as soon as I'll have some free time (and it probably won't be so soon).

If you wish, you can always deep into the source code and implement desired feature by yourself, without awaiting for me to become free enough to start working on it :) If that is the case, then I can provide you brief explanation of how lib works internally

Thanks a lot for your answer ! You're very cool 👍

I found a solution by myself using MotionEvent who works not bad, so i share it because it might be helpful to someone :

               final SlideHolder sh = (SlideHolder) findViewById(R.id.slideHolder);
                       ListView lv = (ListView) findViewById(android.R.id.list);
                lv.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    switch(event.getAction()){
                    case MotionEvent.ACTION_DOWN: 
                        // when user press
                                                    // SlideHolder Allow intercept touch, so horizontally swipe works
                        sh.setAllowInterceptTouch(true);

                        break;
                    case MotionEvent.ACTION_MOVE:
                        // when user swipe
                        // Disable intercept SlideHolder                       
                        sh.setAllowInterceptTouch(false);

                        break; 
                    case MotionEvent.ACTION_UP:
                        // when user leave his finger
                        // Enable intercept SlideHolder                                    
                        sh.setAllowInterceptTouch(true);

                        break; 
                    }
                    return false;
                }
            });

It works perfect !
Keep going your job, google will hire you ;)