本文整理匯總了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) {
//
// }
// });
}