Java Code Examples for android.support.v4.view.ViewPager#setPadding()

The following examples show how to use android.support.v4.view.ViewPager#setPadding() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PagerExampleFragment.java    From ShadowDrawable with MIT License 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
	viewPager = new ViewPager(getActivity());
	viewPager.setClipChildren(false);
	viewPager.setClipToPadding(false);
	int padding = 12 * 3;
	viewPager.setPadding(padding, 0, padding, 0);
	viewPager.setPageMargin(-padding/2);
	return viewPager;
}
 
Example 2
Source File: EmojiBorad.java    From umeng_community_android with MIT License 5 votes vote down vote up
/**
 * create ViewPager view</br>
 * 
 * @return
 */
private ViewPager createVIewpager() {
    ViewPager viewPager = new ViewPager(getContext());
    ViewPager.LayoutParams params = new ViewPager.LayoutParams();
    params.width = android.support.v4.view.ViewPager.LayoutParams.MATCH_PARENT;
    params.height = BOARD_HEIGHT;
    viewPager.setLayoutParams(params);
    viewPager.setPadding(0, 15, 0, 0);
    return viewPager;
}
 
Example 3
Source File: ViewPagerTransformationSampleFragment.java    From oneHookLibraryAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    final int padding = getResources().getDimensionPixelSize(R.dimen.common_margin_medium);

    final ViewPager p1 = view.findViewById(R.id.fragment_sample_view_pagers_p1);
    p1.setPageTransformer(false, new CarouselTransformer(padding, 1));
    p1.setClipChildren(false);
    p1.setClipToPadding(false);
    p1.setPadding(padding, 0, padding, 0);
    p1.setAdapter(new DemoPager(getContext()));

    final ViewPager p1i = view.findViewById(R.id.fragment_sample_view_pagers_p1_infinite);
    p1i.setPageTransformer(false, new CarouselTransformer(padding * 2, 0.9f));
    p1i.setPadding(padding * 2, 0, padding * 2, 0);
    p1i.setClipChildren(false);
    p1i.setClipToPadding(false);
    final InfinitePagerAdapter infiniteAdapter = new InfinitePagerAdapter<>(new DemoPager(getContext()));
    p1i.setAdapter(infiniteAdapter);
    p1i.setCurrentItem(infiniteAdapter.getMidPosition(0));
    final PagerIndicator pagerIndicator = view.findViewById(R.id.fragment_sample_view_pagers_p1_indicator);
    pagerIndicator.setViewPager(p1i);

    final ViewPager p2 = view.findViewById(R.id.fragment_sample_view_pagers_p2);
    p2.setPageTransformer(false, new DepthPageTransformer(true));
    p2.setAdapter(new DemoPager(getContext()));

    final ViewPager p3 = view.findViewById(R.id.fragment_sample_view_pagers_p3);
    p3.setPageTransformer(false, new PagerAlphaTransformer());
    p3.setAdapter(new DemoPager(getContext()));

    final ViewPager p4 = view.findViewById(R.id.fragment_sample_view_pagers_p4);
    p4.setPageTransformer(true, new StackTransformer());
    p4.setAdapter(new DemoPager(getContext()));

    final ViewPager p5 = view.findViewById(R.id.fragment_sample_view_pagers_p5);
    p5.setPageTransformer(true, new ZoomOutTransformer());
    p5.setAdapter(new DemoPager(getContext()));
}
 
Example 4
Source File: DateViewPaperDemo.java    From oneHookLibraryAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    final ViewPager p1 = view.findViewById(R.id.fragment_demo_date_viewpager);
    p1.setClipToPadding(false);
    p1.setPadding(64, 0, 64, 0);
    p1.setPageTransformer(false, new CarouselTransformer(64, 1));
    p1.setAdapter(new FragmentPager(getChildFragmentManager()));
}