List of usage examples for android.view View scrollTo
public void scrollTo(int x, int y)
From source file:ti.modules.titanium.ui.widget.TiUIScrollView.java
public void scrollTo(int x, int y, boolean smoothScroll) { // Fetch the scroll view. final View view = this.scrollView; if (view == null) { return;/*from ww w .ja v a2 s . co m*/ } // Convert the given coordinates to pixels. x = TiConvert.toTiDimension(x, -1).getAsPixels(view); y = TiConvert.toTiDimension(y, -1).getAsPixels(view); // Disable smooth scrolling for vertical scroll views if not at top of view. // Note: This works-around a bug in Google's NestedScrollView where attempting to // smooth scrolls will move to a totally different position or opposite directions. if (smoothScroll && (view instanceof TiVerticalScrollView)) { if (((TiVerticalScrollView) view).getScrollY() > 0) { smoothScroll = false; } } // Scroll to the given position. if (smoothScroll) { if (view instanceof TiHorizontalScrollView) { ((TiHorizontalScrollView) view).smoothScrollTo(x, y); } else if (view instanceof TiVerticalScrollView) { ((TiVerticalScrollView) view).smoothScrollTo(x, y); } } else { view.scrollTo(x, y); } view.computeScroll(); }
From source file:self.philbrown.droidQuery.$.java
/** * Set the horizontal position of the scroll bar for each view in the current selection * @param position the x position to which to scroll * @return this//from w w w. j a v a 2 s . co m */ public $ scrollLeft(int position) { for (int i = 0; i < this.views.size(); i++) { View view = this.views.get(i); view.scrollTo(position, view.getScrollY()); } return this; }
From source file:self.philbrown.droidQuery.$.java
/** * Set the vertical position of the scroll bar for the currently selected views * @param position the scroll position/* w ww . j av a 2s .c o m*/ * @return this */ public $ scrollTop(int position) { for (int i = 0; i < this.views.size(); i++) { View view = this.views.get(i); view.scrollTo(view.getScrollX(), position); } return this; }