本文整理汇总了Java中android.support.v4.view.ViewPager.getChildAt方法的典型用法代码示例。如果您正苦于以下问题:Java ViewPager.getChildAt方法的具体用法?Java ViewPager.getChildAt怎么用?Java ViewPager.getChildAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.view.ViewPager
的用法示例。
在下文中一共展示了ViewPager.getChildAt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCurrentView
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
public View getCurrentView(ViewPager pager) {
for (int i = 0; i < pager.getChildCount(); i++) {
if ((int) pager.getChildAt(i).getTag(R.id.index) == pager.getCurrentItem()) {
return pager.getChildAt(i);
}
}
return null;
}
示例2: onMapSharedElements
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
@Override
public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
View sharedElement = sharedElements.values().iterator().next();
if (sharedElement instanceof ViewPager) {
ViewPager view = (ViewPager) sharedElement;
sharedElements.clear();
View child = view.getChildAt(view.getCurrentItem());
sharedElements.put(names.get(0), child);
} else {
super.onMapSharedElements(names, sharedElements);
}
}
示例3: clampViewPositionVertical
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
/***
* clampViewPositionHorizontal()之后调用
*/
@Override
public int clampViewPositionVertical(final View child, final int top, final int dy) {
if (mScrollChild instanceof ViewPager) {
final ViewPager pager = (ViewPager) mScrollChild;
mScrollChild = pager.getChildAt(pager.getCurrentItem());
final int cacheCount = pager.getChildCount();
int[] points = new int[2];
for (int i = 0; i < cacheCount; i++) {
View view = pager.getChildAt(i);
view.getLocationInWindow(points);
if (mTouchX >= points[0] && mTouchX < points[0] + view.getWidth()) {
mScrollChild = view;
break;
}
}
}
int topBounds;
int bottomBounds;
if (isAllowDragDirection(UP)
&& !childCanScrollDown()
&& top >= mOriginalY
&& mCurDragDirection == UP) {
topBounds = getPaddingTop();
bottomBounds = mVerticalDragRange;
if (null != mOnSwipeBackCallback
&& mOnSwipeBackCallback.onIntercept(mCurDragDirection, mTouchX, mTouchY)
&& mCurDragDirection != NONE
) {
mCurDragDirection = NONE;
return mOriginalY;
}
return Math.min(Math.max(top, topBounds), bottomBounds);
}
if (isAllowDragDirection(DOWN)
&& !childCanScrollUp()
&& top <= mOriginalY
&& mCurDragDirection == DOWN) {
topBounds = -mVerticalDragRange;
bottomBounds = getPaddingTop();
if (null != mOnSwipeBackCallback
&& mOnSwipeBackCallback.onIntercept(mCurDragDirection, mTouchX, mTouchY)
&& mCurDragDirection != NONE
) {
mCurDragDirection = NONE;
return mOriginalY;
}
return Math.min(Math.max(top, topBounds), bottomBounds);
}
return mOriginalY;
}