Java Code Examples for android.view.View#scrollTo()
The following examples show how to use
android.view.View#scrollTo() .
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
Source File: PhotoActivity.java From CrazyDaily with Apache License 2.0 | 6 votes |
@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 2
Source File: PageSlider.java From light-novel-library_Wenku8_Android with GNU General Public License v2.0 | 6 votes |
@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 3
Source File: OverlappedSlider.java From light-novel-library_Wenku8_Android with GNU General Public License v2.0 | 6 votes |
@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 4
Source File: AnimatorProxy.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
public void setScrollX(int i1) { View view = (View)b.get(); if (view != null) { view.scrollTo(i1, view.getScrollY()); } }
Example 5
Source File: PageSlider.java From light-novel-library_Wenku8_Android with GNU General Public License v2.0 | 5 votes |
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 6
Source File: AnimatorProxy.java From zhangshangwuda with Apache License 2.0 | 4 votes |
public void setScrollX(int value) { View view = mView.get(); if (view != null) { view.scrollTo(value, view.getScrollY()); } }
Example 7
Source File: AnimatorProxy.java From Libraries-for-Android-Developers with MIT License | 4 votes |
public void setScrollY(int value) { View view = mView.get(); if (view != null) { view.scrollTo(view.getScrollY(), value); } }
Example 8
Source File: MagicHeaderUtils.java From MagicHeaderViewPager with Apache License 2.0 | 4 votes |
/** * (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; }
Example 9
Source File: AnimatorProxy.java From Mover with Apache License 2.0 | 4 votes |
public void setScrollX(int value) { View view = mView.get(); if (view != null) { view.scrollTo(value, view.getScrollY()); } }
Example 10
Source File: AnimatorProxy.java From android-project-wo2b with Apache License 2.0 | 4 votes |
public void setScrollY(int value) { View view = mView.get(); if (view != null) { view.scrollTo(view.getScrollX(), value); } }
Example 11
Source File: ParallaxHelper.java From Paralloid with Apache License 2.0 | 4 votes |
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 12
Source File: AnimatorProxy.java From CSipSimple with GNU General Public License v3.0 | 4 votes |
public void setScrollY(int value) { View view = mView.get(); if (view != null) { view.scrollTo(view.getScrollY(), value); } }
Example 13
Source File: AnimatorProxy.java From KJFrameForAndroid with Apache License 2.0 | 4 votes |
public void setScrollX(int value) { View view = mView.get(); if (view != null) { view.scrollTo(value, view.getScrollY()); } }
Example 14
Source File: AnimatorProxy.java From UltimateAndroid with Apache License 2.0 | 4 votes |
public void setScrollY(int value) { View view = mView.get(); if (view != null) { view.scrollTo(view.getScrollX(), value); } }
Example 15
Source File: AnimatorProxy.java From android-apps with MIT License | 4 votes |
public void setScrollY(int value) { View view = mView.get(); if (view != null) { view.scrollTo(view.getScrollY(), value); } }
Example 16
Source File: ParallaxHelper.java From Paralloid with Apache License 2.0 | 4 votes |
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 17
Source File: AnimatorProxy.java From zhangshangwuda with Apache License 2.0 | 4 votes |
public void setScrollY(int value) { View view = mView.get(); if (view != null) { view.scrollTo(view.getScrollY(), value); } }
Example 18
Source File: DynamicListLayout.java From dynamiclistview with MIT License | 4 votes |
public void setTopBackgroundViewScrollable(View view, int gapY, int gravity) { view.scrollTo(0, gapY); setDependencyView(view, 0, gapY, gravity); }
Example 19
Source File: AnimatorProxy.java From zen4android with MIT License | 4 votes |
public void setScrollX(int value) { View view = mView.get(); if (view != null) { view.scrollTo(value, view.getScrollY()); } }
Example 20
Source File: AnimatorProxy.java From Libraries-for-Android-Developers with MIT License | 4 votes |
public void setScrollX(int value) { View view = mView.get(); if (view != null) { view.scrollTo(value, view.getScrollY()); } }