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

The following examples show how to use android.support.v4.view.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 atlas 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.base.R.dimen.padding_mini));
    viewPager.setPageMarginDrawable(R.drawable.page_margin);
}
 
Example 2
Source File: MusicMainActivity.java    From mobile-manager-tool with MIT License 6 votes vote down vote up
/**
 * Initiate ViewPager and PagerAdapter
 */
public void initPager() {
    // Initiate PagerAdapter
    PagerAdapter mPagerAdapter = new PagerAdapter(getSupportFragmentManager());

    mPagerAdapter.addFragment(new MusicAllListFragment());
    mPagerAdapter.addFragment(new MusicOnlineFragment());
    mPagerAdapter.addFragment(new MusicLoveListFragment());

    // Initiate ViewPager
    ViewPager mViewPager = (ViewPager)findViewById(R.id.viewPager);
    mViewPager.setPageMargin(getResources().getInteger(R.integer.viewpager_margin_width));
    mViewPager.setPageMarginDrawable(R.drawable.music_viewpager_margin);
    mViewPager.setOffscreenPageLimit(mPagerAdapter.getCount());
    mViewPager.setAdapter(mPagerAdapter);
    // Tabs
    initScrollableTabs(mViewPager);
}
 
Example 3
Source File: MusicLibrary.java    From mobile-manager-tool with MIT License 6 votes vote down vote up
/**
 * Initiate ViewPager and PagerAdapter
 */
public void initPager() {
    // Initiate PagerAdapter
    PagerAdapter mPagerAdapter = new PagerAdapter(getSupportFragmentManager());

    mPagerAdapter.addFragment(new MusicSongListFragment());
    mPagerAdapter.addFragment(new MusicLoveListFragment());

    // Initiate ViewPager
    ViewPager mViewPager = (ViewPager)findViewById(R.id.viewPager);
    mViewPager.setPageMargin(getResources().getInteger(R.integer.viewpager_margin_width));
    mViewPager.setPageMarginDrawable(R.drawable.music_viewpager_margin);
    mViewPager.setOffscreenPageLimit(mPagerAdapter.getCount());
    mViewPager.setAdapter(mPagerAdapter);
    //mViewPager.setCurrentItem(0);

    // Tabs
    initScrollableTabs(mViewPager);
}
 
Example 4
Source File: TracksBrowser.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
/**
 * Initiate ViewPager and PagerAdapter
 */
private void initPager() {
    // Initiate PagerAdapter
    PagerAdapter mPagerAdapter = new PagerAdapter(getSupportFragmentManager());
    if (ApolloUtils.isArtist(mimeType))
        // Show all albums for an artist
        mPagerAdapter.addFragment(new ArtistAlbumsFragment(bundle));
    // Show the tracks for an artist or album
    if(Playlists.CONTENT_TYPE.equals(mimeType)){
        mPagerAdapter.addFragment(new PlaylistListFragment(bundle));
    }
    else if(Genres.CONTENT_TYPE.equals(mimeType)){
    	mPagerAdapter.addFragment(new GenreListFragment(bundle));
    }
    else if(ApolloUtils.isArtist(mimeType)){
    	mPagerAdapter.addFragment(new ArtistListFragment(bundle));
    }
    else if(Audio.Albums.CONTENT_TYPE.equals(mimeType)){
    	mPagerAdapter.addFragment(new AlbumListFragment(bundle));
    }

    // Set up ViewPager
    mViewPager = (ViewPager)findViewById(R.id.viewPager);
    mViewPager.setPageMargin(getResources().getInteger(R.integer.viewpager_margin_width));
    mViewPager.setPageMarginDrawable(R.drawable.music_viewpager_margin);
    mViewPager.setOffscreenPageLimit(mPagerAdapter.getCount());
    mViewPager.setAdapter(mPagerAdapter);
    mViewPager.setOnPageChangeListener(new PageListener());
}
 
Example 5
Source File: NetworkMonitorActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(final Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	overridePendingTransition(R.anim.slide_in_right, 0);
	setContentView(R.layout.network_monitor_content);

	// final ActionBar actionBar = getSupportActionBar();
	// actionBar.setDisplayHomeAsUpEnabled(true);

	final ViewPager pager = (ViewPager) findViewById(R.id.network_monitor_pager);

	final FragmentManager fm = getSupportFragmentManager();

	if (pager != null) {
		final ViewPagerTabs pagerTabs = (ViewPagerTabs) findViewById(R.id.network_monitor_pager_tabs);
		pagerTabs.addTabLabels(R.string.network_monitor_peer_list_title,
				R.string.network_monitor_block_list_title);

		final PagerAdapter pagerAdapter = new PagerAdapter(fm);

		pager.setAdapter(pagerAdapter);
		pager.setOnPageChangeListener(pagerTabs);
		pager.setPageMargin(2);
		pager.setPageMarginDrawable(R.color.bg);

		peerListFragment = new PeerListFragment();
		blockListFragment = new BlockListFragment();
	} else {
		peerListFragment = (PeerListFragment) fm
				.findFragmentById(R.id.peer_list_fragment);
		blockListFragment = (BlockListFragment) fm
				.findFragmentById(R.id.block_list_fragment);
	}
	// flTitleBar = (FrameLayout) findViewById(R.id.fl_title_bar);
	ibtnBack = (ImageButton) findViewById(R.id.ibtn_back);
	ibtnBack.setOnClickListener(new IBackClickListener());
       findViewById(R.id.ibtn_option).setOnClickListener(optionClick);
   }
 
Example 6
Source File: MainActivity.java    From ResearchStack with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LogExt.d(getClass(), "onCreate");

    setContentView(R.layout.rss_activity_main);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(true);

    if (pagerAdapter == null) {
        List<ActionItem> items = UiManager.getInstance().getMainTabBarItems();
        pagerAdapter = new MainPagerAdapter(getSupportFragmentManager(), items);

        ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
        viewPager.setAdapter(pagerAdapter);
        viewPager.setPageMargin(1);
        viewPager.setPageMarginDrawable(new ColorDrawable(Color.LTGRAY));

        IconTabLayout tabLayout = (IconTabLayout) findViewById(R.id.tabLayout);
        tabLayout.setOnTabSelectedListener(new IconTabLayout.OnTabSelectedListenerAdapter() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                int index = tabLayout.getSelectedTabPosition();
                viewPager.setCurrentItem(index);
            }
        });

        for (ActionItem item : items) {
            tabLayout.addIconTab(
                    item.getTitle(),
                    item.getIcon(),
                    items.indexOf(item) == 0,
                    // need real logic for this (show badge)
                    items.indexOf(item) == 0
            );
        }

        viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
    }

    handleNotificationIntent(getIntent());
}