Search This Blog

Showing posts with label Tablayout. Show all posts
Showing posts with label Tablayout. Show all posts

Tuesday, September 19, 2017

Gắn hiệu ứng chuyễn động cho pageView

mPager = (ViewPager) findViewById(R.id.pager); //the UI pagermPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
mPager.setAdapter(mPagerAdapter);
mPager.setPageTransformer(true, new RotateDownTransformer()); //set the animation

Thursday, July 13, 2017

Di chuyễn tới tab được chọn

tabLayout.getTabAt(4).select();

Sự kiện chọn vào Tablayout

tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
    @Override
    public void onTabSelected(TabLayout.Tab tab) {
        if(tab.getPosition()==1){
                tabLayout.setTabTextColors(ContextCompat.getColor(getActivity(), R.color.unselected_tab),ContextCompat.getColor(getActivity(), R.color.tab_selection));
            }else{
                tabLayout.setTabTextColors(ContextCompat.getColor(getActivity(), R.color.unselected_tab),ContextCompat.getColor(getActivity(), R.color.white));

            }

 // same thing goes with other tabs too
 // Just change your tab text on selected/deselected as above

    }

    @Override
    public void onTabUnselected(TabLayout.Tab tab) {
        tab.setCustomView(null);
    }

    @Override
    public void onTabReselected(TabLayout.Tab tab) {

    }
});