how to find end of scroll value for HorizontalScrollView

Posted by DroidCoder on Stack Overflow See other posts from Stack Overflow or by DroidCoder
Published on 2012-09-03T06:31:27Z Indexed on 2012/09/13 9:38 UTC
Read the original article Hit count: 276

i need to implement following scenario,

here i have two horizontalScrollViews the upper scrollView is a main menu and lower scrollView is a submenu.

when i scroll main menu,the menu which comes under center arrow will show its submenu in lower scrollview and from the lower scrollview, the submenu which comes under center arrow shows the screen for that sub-menu.

here's my requirement:enter image description here

i've implemented it using HorizontalScrollViews and ViewFlipper and also it works but it will give correct result only when i scroll it slowly and not when scroll fast.

i've used onTouch() method with a ACTION_UP event,so when i release finger from screen it will gives me getScrollX() position at that point but here i need getScrollX() position when scroll is finished/stop.

here's my code:-

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

            case R.id.mHorizontalScrollViewMain:
           if (event.getAction() == KeyEvent.ACTION_UP) {
            Log.d("test", " " + hsvUpperTab.getScrollX() + " , "+ mViewFlipper.getChildCount());
            getUpperTabScrolled(hsvUpperTab.getScrollX());
        }
        break;

        case R.id.mHorizontalScrollViewSub:
                if (event.getAction() == KeyEvent.ACTION_UP) {
            Log.d("test1", " " + hsvLowerTab.getScrollX());
            getLowerTabScrolled(hsvLowerTab.getScrollX());

            }

        default:
            break;

        }

        return false;
    }

© Stack Overflow or respective owner

Related posts about android

Related posts about scrollbar