Java Code Examples for androidx.viewpager.widget.ViewPager#setPageMarginDrawable()

The following examples show how to use androidx.viewpager.widget.ViewPager#setPageMarginDrawable() . 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: DetailActivity.java    From animation-samples with Apache License 2.0 6 votes vote down vote up
private void setUpViewPager(ArrayList<Photo> photos) {
    viewPager = (ViewPager) findViewById(R.id.pager);
    viewPager.setAdapter(new DetailViewPagerAdapter(this, photos, sharedElementCallback));
    viewPager.setCurrentItem(initialItem);

    viewPager.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom,
                                   int oldLeft, int oldTop, int oldRight, int oldBottom) {
            if (viewPager.getChildCount() > 0) {
                viewPager.removeOnLayoutChangeListener(this);
                startPostponedEnterTransition();
            }
        }
    });

    viewPager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.padding_mini));
    viewPager.setPageMarginDrawable(R.drawable.page_margin);
}
 
Example 2
Source File: DetailActivity.java    From android-instant-apps with Apache License 2.0 6 votes vote down vote up
private void setUpViewPager(ArrayList<Photo> photos) {
    viewPager = (ViewPager) findViewById(R.id.pager);
    viewPager.setAdapter(new DetailViewPagerAdapter(this, photos, sharedElementCallback));
    viewPager.setCurrentItem(initialItem);

    viewPager.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom,
                                   int oldLeft, int oldTop, int oldRight, int oldBottom) {
            if (viewPager.getChildCount() > 0) {
                viewPager.removeOnLayoutChangeListener(this);
                startPostponedEnterTransition();
            }
        }
    });

    viewPager.setPageMargin(getResources().getDimensionPixelSize(
            com.example.android.unsplash.R.dimen.padding_mini));
    viewPager.setPageMarginDrawable(R.drawable.page_margin);
}
 
Example 3
Source File: ClusterMapActivity.java    From intra42 with Apache License 2.0 6 votes vote down vote up
@Override
public void setupViewPager(ViewPager viewPager) {
    ViewStatePagerAdapter adapter = new ViewStatePagerAdapter(getSupportFragmentManager());

    adapter.addFragment(ClusterMapInfoFragment.newInstance(), getString(R.string.title_tab_cluster_map_info));

    if (clusterData.clusters != null)
        for (Cluster i : clusterData.clusters) {
            adapter.addFragment(ClusterMapFragment.newInstance(i.hostPrefix), i.nameShort);
        }

    viewPager.setAdapter(adapter);

    viewPager.setPageMargin(20);
    viewPager.setPageMarginDrawable(R.color.textColorBlackPrimary);
    ((CustomViewPager) viewPager).setPagingEnabled(false);
}
 
Example 4
Source File: ItemPagerAdapter.java    From materialistic with Apache License 2.0 5 votes vote down vote up
public void bind(ViewPager viewPager, TabLayout tabLayout,
                 FloatingActionButton navigationFab, FloatingActionButton genericFab) {
    viewPager.setPageMargin(viewPager.getResources().getDimensionPixelOffset(R.dimen.divider));
    viewPager.setPageMarginDrawable(R.color.blackT12);
    viewPager.setOffscreenPageLimit(2);
    viewPager.setAdapter(this);
    tabLayout.setupWithViewPager(viewPager);
    mTabListener = new TabLayout.ViewPagerOnTabSelectedListener(viewPager) {
        @Override
        public void onTabSelected(TabLayout.Tab tab) {
            super.onTabSelected(tab);
            toggleFabs(viewPager.getCurrentItem() == 0, navigationFab, genericFab);
            Fragment fragment = getItem(viewPager.getCurrentItem());
            if (fragment != null) {
                ((LazyLoadFragment) fragment).loadNow();
            }
        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {
            Fragment fragment = getItem(viewPager.getCurrentItem());
            if (fragment != null) {
                ((Scrollable) fragment).scrollToTop();
            }
        }
    };
    tabLayout.addOnTabSelectedListener(mTabListener);
    viewPager.setCurrentItem(mDefaultItem);
    toggleFabs(mDefaultItem == 0, navigationFab, genericFab);

}