Example usage for android.widget HorizontalScrollView getScrollX

List of usage examples for android.widget HorizontalScrollView getScrollX

Introduction

In this page you can find the example usage for android.widget HorizontalScrollView getScrollX.

Prototype

public final int getScrollX() 

Source Link

Document

Return the scrolled left position of this view.

Usage

From source file:com.facebook.react.views.scroll.ReactHorizontalScrollContainerView.java

@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    if (mLayoutDirection == LAYOUT_DIRECTION_RTL) {
        // When the layout direction is RTL, we expect Yoga to give us a layout
        // that extends off the screen to the left so we re-center it with left=0
        int newLeft = 0;
        int width = right - left;
        int newRight = newLeft + width;
        setLeft(newLeft);/*w  w  w  . j  a v  a2  s  .co m*/
        setRight(newRight);

        // Call with the present values in order to re-layout if necessary
        HorizontalScrollView parent = (HorizontalScrollView) getParent();
        // Fix the ScrollX position when using RTL language
        int offsetX = parent.getScrollX() + getWidth() - mCurrentWidth;
        parent.scrollTo(offsetX, parent.getScrollY());
    }
    mCurrentWidth = getWidth();
}

From source file:com.cachirulop.moneybox.fragment.MoneyboxFragment.java

/**
 * Move an image of the money like it was dropping inside the money box
 * //from  www. ja v  a2 s . c o m
 * @param src
 *            Image of the money to drop
 * @param m
 *            Movement with the value of the money to drop
 */

private void dropMoney(View src, Movement m) {
    HorizontalScrollView scroll;

    scroll = (HorizontalScrollView) getActivity().findViewById(R.id.scrollButtonsView);

    dropMoney(src.getLeft() - scroll.getScrollX(), src.getRight(), m);
}

From source file:com.youle.gamebox.ui.view.SlidingPaneLayout.java

private boolean isTargetViewOnLeft() {
    boolean result = false;
    if (mTargetView != null) {
        if (mTargetView instanceof HorizontalScrollView) {
            HorizontalScrollView scrollView = (HorizontalScrollView) mTargetView;
            result = scrollView.getScrollX() <= 0;
        } else if (mTargetView instanceof ViewPager) {
            ViewPager pager = (ViewPager) mTargetView;
            PagerAdapter adapter = pager.getAdapter();
            boolean canTurnLeft = adapter != null && adapter.getCount() > 0 && pager.getCurrentItem() > 0;
            result = !canTurnLeft;//  ww w.j a  v  a 2 s . c om
        }
    }
    return result;
}

From source file:com.youle.gamebox.ui.view.SlidingPaneLayout.java

private boolean isTargetViewOnRight() {
    boolean result = false;
    if (mTargetView != null) {
        if (mTargetView instanceof HorizontalScrollView) {
            HorizontalScrollView scrollView = (HorizontalScrollView) mTargetView;
            // ScrollView????View?
            View child = scrollView.getChildAt(0);
            if (child != null) {
                result = child.getMeasuredWidth() <= getWidth() + scrollView.getScrollX();
            }// w  w  w  . j av a2s  .  c om
        } else if (mTargetView instanceof ViewPager) {
            ViewPager pager = (ViewPager) mTargetView;
            PagerAdapter adapter = pager.getAdapter();
            boolean canTurnRight = adapter != null && adapter.getCount() > 0
                    && pager.getCurrentItem() < adapter.getCount() - 1;
            result = !canTurnRight;
        }
    }
    return result;
}