Java Code Examples for android.view.View#scrollTo()

The following examples show how to use android.view.View#scrollTo() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
public void resetFromAdapter(SlidingAdapter adapter) {
    mSlidingLayout.addView(getAdapter().getCurrentView());

    if (getAdapter().hasNext()) {
        View nextView = getAdapter().getNextView();
        mSlidingLayout.addView(nextView, 0);
        nextView.scrollTo(0, 0);
    }

    if (getAdapter().hasPrevious()) {
        View prevView = getAdapter().getPreviousView();
        mSlidingLayout.addView(prevView);
        prevView.scrollTo(screenWidth, 0);
    }

    mSlidingLayout.slideSelected(getAdapter().getCurrent());
}
 
Example 2
Source Project: CrazyDaily   File: PhotoActivity.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({"SuspiciousNameCombination", "UnnecessaryLocalVariable"})
@Override
public void onDrawerSlide(@NonNull View drawerView, float slideOffset) {
    mDrawerToggle.onDrawerSlide(drawerView, slideOffset);
    final View content = mPhotoDrawer.getChildAt(0);
    final View menu = drawerView;
    final float leftScale = SCALE_RATIO + (1 - SCALE_RATIO) * slideOffset;
    final float rightScale = 1 - (1 - SCALE_RATIO) * slideOffset;
    final int slideWidth = menu.getMeasuredWidth();
    //设置缩放基点
    menu.setPivotX(menu.getMeasuredWidth());
    menu.setScaleX(leftScale);
    menu.setScaleY(leftScale);
    menu.setAlpha(ALPHA_RATIO + (1 - ALPHA_RATIO) * slideOffset);
    //setTranslationX会超出区域,不美观,但scrollTo也存在缺点
    menu.scrollTo((int) (-slideWidth * SCROLL_RATIO * (1 - slideOffset)), 0);
    content.setTranslationX(slideWidth * slideOffset);
    content.setPivotX(0);
    content.setScaleX(rightScale);
    content.setScaleY(rightScale);
}
 
Example 3
@Override
public void resetFromAdapter(SlidingAdapter adapter) {
    View curView = getAdapter().getUpdatedCurrentView();
    mSlidingLayout.addView(curView);
    curView.scrollTo(0, 0);

    if (getAdapter().hasPrevious()) {
        View prevView = getAdapter().getUpdatedPreviousView();
        mSlidingLayout.addView(prevView);
        prevView.scrollTo(screenWidth, 0);
    }


    if (getAdapter().hasNext()) {
        View nextView = getAdapter().getUpdatedNextView();
        mSlidingLayout.addView(nextView);
        nextView.scrollTo(-screenWidth, 0);
    }

    mSlidingLayout.slideSelected(getAdapter().getCurrent());
}
 
Example 4
private boolean moveToNext() {
    if (!getAdapter().hasNext())
        return false;

    // Move top view to bottom view
    View prevView = getAdapter().getPreviousView();
    if (prevView != null)
        mSlidingLayout.removeView(prevView);
    View newNextView = prevView;

    getAdapter().moveToNext();

    mSlidingLayout.slideSelected(getAdapter().getCurrent());

    if (getAdapter().hasNext()) {
        // Update content in the old view
        if (newNextView != null) {
            View updateNextView = getAdapter().getView(newNextView, getAdapter().getNext());
            if (updateNextView != newNextView) {
                getAdapter().setNextView(updateNextView);
                newNextView = updateNextView;
            }
        } else {
            newNextView = getAdapter().getNextView();
        }
        newNextView.scrollTo(-screenWidth, 0);
        mSlidingLayout.addView(newNextView);
    }

    return true;
}
 
Example 5
Source Project: MiBandDecompiled   File: AnimatorProxy.java    License: Apache License 2.0 5 votes vote down vote up
public void setScrollX(int i1)
{
    View view = (View)b.get();
    if (view != null)
    {
        view.scrollTo(i1, view.getScrollY());
    }
}
 
Example 6
Source Project: UltimateAndroid   File: AnimatorProxy.java    License: Apache License 2.0 4 votes vote down vote up
public void setScrollY(int value) {
    View view = mView.get();
    if (view != null) {
        view.scrollTo(view.getScrollX(), value);
    }
}
 
Example 7
public void setScrollY(int value) {
    View view = mView.get();
    if (view != null) {
        view.scrollTo(view.getScrollY(), value);
    }
}
 
Example 8
Source Project: zen4android   File: AnimatorProxy.java    License: MIT License 4 votes vote down vote up
public void setScrollX(int value) {
    View view = mView.get();
    if (view != null) {
        view.scrollTo(value, view.getScrollY());
    }
}
 
Example 9
Source Project: KJFrameForAndroid   File: AnimatorProxy.java    License: Apache License 2.0 4 votes vote down vote up
public void setScrollX(int value) {
    View view = mView.get();
    if (view != null) {
        view.scrollTo(value, view.getScrollY());
    }
}
 
Example 10
public void setScrollX(int value) {
    View view = mView.get();
    if (view != null) {
        view.scrollTo(value, view.getScrollY());
    }
}
 
Example 11
Source Project: dynamiclistview   File: DynamicListLayout.java    License: MIT License 4 votes vote down vote up
public void setTopBackgroundViewScrollable(View view, int gapY, int gravity) {
    view.scrollTo(0, gapY);
    setDependencyView(view, 0, gapY, gravity);
}
 
Example 12
Source Project: zhangshangwuda   File: AnimatorProxy.java    License: Apache License 2.0 4 votes vote down vote up
public void setScrollY(int value) {
    View view = mView.get();
    if (view != null) {
        view.scrollTo(view.getScrollY(), value);
    }
}
 
Example 13
Source Project: Paralloid   File: ParallaxHelper.java    License: Apache License 2.0 4 votes vote down vote up
public static void scrollViewBy(final View view, final int x, final int y, final float factor) {
    if (view == null) return;
    view.scrollTo((int) (x * factor), (int) (y * factor));
}
 
Example 14
Source Project: android-apps   File: AnimatorProxy.java    License: MIT License 4 votes vote down vote up
public void setScrollY(int value) {
    View view = mView.get();
    if (view != null) {
        view.scrollTo(view.getScrollY(), value);
    }
}
 
Example 15
Source Project: zhangshangwuda   File: AnimatorProxy.java    License: Apache License 2.0 4 votes vote down vote up
public void setScrollX(int value) {
    View view = mView.get();
    if (view != null) {
        view.scrollTo(value, view.getScrollY());
    }
}
 
Example 16
public void setScrollY(int value) {
    View view = mView.get();
    if (view != null) {
        view.scrollTo(view.getScrollY(), value);
    }
}
 
Example 17
Source Project: Paralloid   File: ParallaxHelper.java    License: Apache License 2.0 4 votes vote down vote up
public static void scrollViewBy(final View view, final int x, final int y, final Transformer transformer, final float factor) {
    if (view == null || transformer == null) return;
    final int[] transform = transformer.scroll(x, y, factor);
    view.scrollTo(transform[0], transform[1]);
}
 
Example 18
public void setScrollY(int value) {
    View view = mView.get();
    if (view != null) {
        view.scrollTo(view.getScrollX(), value);
    }
}
 
Example 19
Source Project: Mover   File: AnimatorProxy.java    License: Apache License 2.0 4 votes vote down vote up
public void setScrollX(int value) {
    View view = mView.get();
    if (view != null) {
        view.scrollTo(value, view.getScrollY());
    }
}
 
Example 20
/**
     * (as its name)
     * @param view
     * @param translation_Y Positive when upwards
     * @param translationMethod
     * @return true if success
     */
    @SuppressLint("NewApi")
    public static boolean setParamY(View view, int translation_Y, int translationMethod) {
        if (view == null) {
            Log.e(TAG, "ERROR: warning: your params contains null in setParamY()");
            return false;
        }
        boolean result;
        switch (translationMethod) {
            case TranslationMethods.VIEW_SCROLL:
                if(translation_Y != view.getScrollY()) {
                    view.scrollTo(0, translation_Y);
                    result = true;
                } else {
                    result = false;
                }
                break;
            case TranslationMethods.LAYOUT_PARAMS:
                translation_Y = -translation_Y;
                ViewGroup.LayoutParams lp = view.getLayoutParams();
                if (!(lp instanceof FrameLayout.LayoutParams)) {
//                    Log.w(TAG, "Warning: view " + view + "'s parent must be FrameLayout T.T");
                    return false;
                }
                FrameLayout.LayoutParams fl_lp = (FrameLayout.LayoutParams) lp;
                if (translation_Y != fl_lp.topMargin) {
                    fl_lp.topMargin = translation_Y;
                    view.requestLayout();
                    result = true;
                } else {
                    result = false;
                }
                break;
            case TranslationMethods.SET_TRANSLATION:
                translation_Y = -translation_Y;
                view.setTranslationY(translation_Y);
                result = true;
                break;
            default:
                Log.e(TAG, "ERROR:Sorry. in setParamY, what is your TranslationMethods?");
                result = false;
        }
        return result;
    }