本文整理汇总了Java中android.support.v4.view.ViewPager.setClipChildren方法的典型用法代码示例。如果您正苦于以下问题:Java ViewPager.setClipChildren方法的具体用法?Java ViewPager.setClipChildren怎么用?Java ViewPager.setClipChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.view.ViewPager
的用法示例。
在下文中一共展示了ViewPager.setClipChildren方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
private void init(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.XGallery, defStyleAttr, 0);
int itemWidth = a.getDimensionPixelOffset(R.styleable.XGallery_xGallery_itemWidth, LayoutParams.MATCH_PARENT);
int itemHeight = a.getDimensionPixelOffset(R.styleable.XGallery_xGallery_itemHeight, LayoutParams.MATCH_PARENT);
a.recycle();
mViewPager = new ViewPager(context);
mViewPager.setClipChildren(false);
mViewPager.setOverScrollMode(OVER_SCROLL_NEVER);
mViewPager.setHorizontalScrollBarEnabled(false);
mViewPager.setOffscreenPageLimit(5);
setPageTransformer(new BottomScalePageTransformer());
LayoutParams params = new LayoutParams(itemWidth, itemHeight);
params.gravity = Gravity.CENTER;
addView(mViewPager, params);
setClipChildren(false);
setOnTouchListener(this);
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
mTapTimeout = ViewConfiguration.getTapTimeout();
mViewPagerWidth = itemWidth;
}
示例2: setupViewPager
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
public static void setupViewPager(final ViewPager viewPager) {
ViewGroup.LayoutParams layoutParams = viewPager.getLayoutParams();
layoutParams.width = ((Activity) viewPager.getContext()).getWindowManager().getDefaultDisplay().getWidth() / 7 * 5;
layoutParams.height = (int) ((layoutParams.width / 0.75));
viewPager.setOffscreenPageLimit(2);
if (viewPager.getParent() instanceof ViewGroup) {
ViewGroup viewParent = ((ViewGroup) viewPager.getParent());
viewParent.setClipChildren(false);
viewPager.setClipChildren(false);
}
viewPager.setPageTransformer(true, new ExpandingViewPagerTransformer());
// viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
// @Override
// public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
// ExpandingFragment expandingFragment = getCurrentFragment(viewPager);
// if(expandingFragment != null && expandingFragment.isOpenend()){
// expandingFragment.close();
// }
// }
//
// @Override
// public void onPageSelected(int position) {
//
// }
//
// @Override
// public void onPageScrollStateChanged(int state) {
//
// }
// });
}