List of usage examples for android.view View getLeft
@ViewDebug.CapturedViewProperty public final int getLeft()
From source file:android.support.design.widget.TabLayout.java
private int calculateScrollXForTab(int position, float positionOffset) { if (mMode == MODE_SCROLLABLE) { final View selectedChild = mTabStrip.getChildAt(position); final View nextChild = position + 1 < mTabStrip.getChildCount() ? mTabStrip.getChildAt(position + 1) : null;//from w w w. j av a 2 s. c o m final int selectedWidth = selectedChild != null ? selectedChild.getWidth() : 0; final int nextWidth = nextChild != null ? nextChild.getWidth() : 0; // base scroll amount: places center of tab in center of parent int scrollBase = selectedChild.getLeft() + (selectedWidth / 2) - (getWidth() / 2); // offset amount: fraction of the distance between centers of tabs int scrollOffset = (int) ((selectedWidth + nextWidth) * 0.5f * positionOffset); return (ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_LTR) ? scrollBase + scrollOffset : scrollBase - scrollOffset; } return 0; }
From source file:cn.iterlog.myapplication.widget.overscroll.StaggeredGridView.java
@Override public Parcelable onSaveInstanceState() { final Parcelable superState = super.onSaveInstanceState(); final SavedState ss = new SavedState(superState); final int position = mFirstPosition; ss.position = mFirstPosition;/*from www .j a v a 2 s. c o m*/ if (position >= 0 && mAdapter != null && position < mAdapter.getCount()) { ss.firstId = mAdapter.getItemId(position); } if (getChildCount() > 0) { int topOffsets[] = new int[this.mColCount]; if (this.mColWidth > 0) for (int i = 0; i < mColCount; i++) { if (getChildAt(i) != null) { final View child = getChildAt(i); final int left = child.getLeft(); int col = 0; Log.w("mColWidth", mColWidth + " " + left); // determine the column by cycling widths while (left > col * (this.mColWidth + mItemMargin * 2) + getPaddingLeft()) { col++; } topOffsets[col] = getChildAt(i).getTop() - mItemMargin - getPaddingTop(); } } ss.topOffsets = topOffsets; // convert nested arraylist so it can be parcelable ArrayList<ColMap> convert = new ArrayList<ColMap>(); for (HashSet<Integer> cols : mColMappings) { convert.add(new ColMap(new ArrayList<Integer>(cols))); } ss.mapping = convert; } return ss; }
From source file:cn.iterlog.myapplication.widget.overscroll.StaggeredGridView.java
private View getFirstChildAtColumn(int column) { if (this.getChildCount() > column) { for (int i = 0; i < this.mColCount; i++) { final View child = getChildAt(i); if (child != null) { final int left = child.getLeft(); int col = 0; // determine the column by cycling widths while (left > col * (this.mColWidth + mItemMargin * 2) + getPaddingLeft()) { col++;/*w ww . j av a 2s .co m*/ } if (col == column) { return child; } } } } return null; }
From source file:com.android.slidingmenu.HorizontalListView.java
private void removeNonVisibleChildren(final int dx) { View child = getLeftmostChild(); // Loop removing the leftmost child, until that child is on the screen while (child != null && child.getRight() + dx <= 0) { // The child is being completely removed so remove its width from // the display offset and its divider if it has one. // To remove add the size of the child and its divider (if it has // one) to the offset. // You need to add since its being removed from the left side, i.e. // shifting the offset to the right. mDisplayOffset += isLastItemInAdapter(mLeftViewAdapterIndex) ? child.getMeasuredWidth() : mDividerWidth + child.getMeasuredWidth(); // Add the removed view to the cache recycleView(mLeftViewAdapterIndex, child); // Actually remove the view removeViewInLayout(child);// w w w . j a v a2 s .com // Keep track of the adapter index of the left most child mLeftViewAdapterIndex++; // Get the new leftmost child child = getLeftmostChild(); } child = getRightmostChild(); // Loop removing the rightmost child, until that child is on the screen while (child != null && child.getLeft() + dx >= getWidth()) { recycleView(mRightViewAdapterIndex, child); removeViewInLayout(child); mRightViewAdapterIndex--; child = getRightmostChild(); } }
From source file:com.brantapps.viewpagerindicator.vertical.VerticalViewPager.java
/** * Tests scrollability within child views of v given a delta of dy. * * @param v View to test for horizontal scrollability * @param checkV Whether the view v passed should itself be checked for scrollability (true), * or just its children (false). * @param dy Delta scrolled in pixels/*from w w w .j a va 2s .c om*/ * @param x X coordinate of the active touch point * @param y Y coordinate of the active touch point * @return true if child views of v can be scrolled by delta of dy. */ // BrantApps Change: Renamed dx to dy protected boolean canScroll(View v, boolean checkV, int dy, int x, int y) { if (v instanceof ViewGroup) { final ViewGroup group = (ViewGroup) v; final int scrollX = v.getScrollX(); final int scrollY = v.getScrollY(); final int count = group.getChildCount(); // Count backwards - let topmost views consume scroll distance first. for (int i = count - 1; i >= 0; i--) { // TODO: Add versioned support here for transformed views. // This will not work for transformed views in Honeycomb+ final View child = group.getChildAt(i); if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child, true, dy, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; } } } // BrantApps Change: Replaced canScrollHorizontally with canScrollVertically return checkV && ViewCompat.canScrollVertically(v, -dy); }
From source file:chan.android.app.bitwise.util.StaggeredGridView.java
final void offsetChildren(int offset) { final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); child.layout(child.getLeft(), child.getTop() + offset, child.getRight(), child.getBottom() + offset); }// w w w.jav a 2s.co m final int colCount = mColCount; for (int i = 0; i < colCount; i++) { mItemTops[i] += offset; mItemBottoms[i] += offset; } }
From source file:chan.android.app.bitwise.util.StaggeredGridView.java
private View getFirstChildAtColumn(int column) { if (this.getChildCount() > column) { for (int i = 0; i < this.mColCount; i++) { final View child = getChildAt(i); final int left = child.getLeft(); if (child != null) { int col = 0; // determine the column by cycling widths while (left > col * (this.mColWidth + mItemMargin * 2) + getPaddingLeft()) { col++;//from ww w .j a v a2 s .c om } if (col == column) { return child; } } } } return null; }
From source file:com.app.afteryou.ui.staggered.StaggeredGridView.java
@Override public Parcelable onSaveInstanceState() { final Parcelable superState = super.onSaveInstanceState(); final SavedState ss = new SavedState(superState); final int position = mFirstPosition; ss.position = position;// w w w .ja v a 2 s.com if (position >= 0 && mAdapter != null && position < mAdapter.getCount()) { ss.firstId = mAdapter.getItemId(position); } if (getChildCount() > 0) { int topOffsets[] = new int[this.mColCount]; if (this.mColWidth > 0) for (int i = 0; i < mColCount; i++) { if (getChildAt(i) != null) { final View child = getChildAt(i); final int left = child.getLeft(); int col = 0; // determine the column by cycling widths while (left > col * (this.mColWidth + mItemMargin * 2) + getPaddingLeft()) { col++; } topOffsets[col] = getChildAt(i).getTop() - mItemMargin - getPaddingTop(); } } ss.topOffsets = topOffsets; // convert nested arraylist so it can be parcelable ArrayList<ColMap> convert = new ArrayList<ColMap>(); for (ArrayList<Integer> cols : mColMappings) { convert.add(new ColMap(cols)); } ss.mapping = convert; } return ss; }
From source file:chan.android.app.bitwise.util.StaggeredGridView.java
@Override public Parcelable onSaveInstanceState() { final Parcelable superState = super.onSaveInstanceState(); final SavedState ss = new SavedState(superState); final int position = mFirstPosition; ss.position = mFirstPosition;/*from w ww . j a va2s.c o m*/ if (position >= 0 && mAdapter != null && position < mAdapter.getCount()) { ss.firstId = mAdapter.getItemId(position); } if (getChildCount() > 0) { int topOffsets[] = new int[this.mColCount]; if (this.mColWidth > 0) for (int i = 0; i < mColCount; i++) { if (getChildAt(i) != null) { final View child = getChildAt(i); final int left = child.getLeft(); int col = 0; Log.w("mColWidth", mColWidth + " " + left); // determine the column by cycling widths while (left > col * (this.mColWidth + mItemMargin * 2) + getPaddingLeft()) { col++; } topOffsets[col] = getChildAt(i).getTop() - mItemMargin - getPaddingTop(); } } ss.topOffsets = topOffsets; // convert nested arraylist so it can be parcelable ArrayList<ColMap> convert = new ArrayList<ColMap>(); for (ArrayList<Integer> cols : mColMappings) { convert.add(new ColMap(cols)); } ss.mapping = convert; } return ss; }
From source file:com.app.afteryou.ui.staggered.StaggeredGridView.java
private View getFirstChildAtColumn(int column) { if (this.getChildCount() > column) { for (int i = 0; i < this.mColCount; i++) { final View child = getChildAt(i); if (child != null) { final int left = child.getLeft(); int col = 0; // determine the column by cycling widths while (left > col * (this.mColWidth + mItemMargin * 2) + getPaddingLeft()) { col++;//from www. j av a 2s. c om } if (col == column) { return child; } } } } return null; }