Question

I would like to use the SystemUiHider activity setup to create an interface where some elements in top and bottom menus are hidden on scrolls downward. But revealed on touch and scrolls upward.

The default SystemUiHider has this method to do detect gestures

// Set up the user interaction to manually show or hide the system UI.
    contentView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (TOGGLE_ON_CLICK) {
                mSystemUiHider.toggle();
            } else {
                mSystemUiHider.show();
            }
        }

        //want an onscrolldown listener
    });

how would I modify this to detect the kind of information I want. Can the OnClickListener detect scrolls? Or do I need a different kind of listener or a custom gesture implemented.

Was it helpful?

Solution 2

I am not sure if I understood correctly.But, I guess you are looking for gesture detection. In that case set onTouchListener for it and Override onTouchListener

@Override
public boolean onTouch(View v, MotionEvent event) {

    switch (event.getAction())
    {
    case MotionEvent.ACTION_DOWN:
    {
        canHandleMove=true;
        lastY = touchevent.getY();
        Log.d("tag", "touch down at "+lastX);
        break;
    }

    case MotionEvent.ACTION_UP:
    case MotionEvent.ACTION_MOVE:
    {
        if(canHandleMove)
        {
        canHandleMove=false;
        float currentY = event.getY();
        Log.d("tag", "touch up at "+currentY);

        float diff=((lastY<currentY)?(currentY-lastY):(lastY-currentY));
        if(diff>10)
        {
        if (lastY < currentY)
        {
            // Move Up
        }
        if (lastY > currentY)
        {
            // Move Down
        }
        }
        break;
        }
    }
    }
    return true;
}

OTHER TIPS

The LarsWerkman QuickReturnListView open source project seems to do what your hoping for. Include it your project to see if it fulfil your requirements or take a peak on how they implement and customized to your needs.

https://github.com/LarsWerkman/QuickReturnListView

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top