@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.wishlist_and_cart_activity_layout); toolbar = (Toolbar) findViewById(R.id.toolbar); appBarLayout = (AppBarLayout) findViewById(R.id.appbarlayout); viewPager = (ViewPager) findViewById(R.id.pager_shopandcart); pagerSlidingTabStrip = (PagerSlidingTabStrip) findViewById(R.id.tabstripcartwishlist); floatingActionButton = (FloatingActionButton) findViewById(R.id.fab_cart); coordinatorLayout = (CoordinatorLayout) findViewById(R.id.cordinatorwishlist); floatingActionButton.setOnClickListener(this); toolbar .getViewTreeObserver() .addOnGlobalLayoutListener( new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { toolbarHeight = toolbar.getHeight(); } }); setSupportActionBar(toolbar); getSupportActionBar().setTitle(""); getSupportActionBar().setDisplayHomeAsUpEnabled(true); toolbar.setBackgroundColor(getResources().getColor(R.color.PrimaryColor)); adapter = new MyPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(adapter); pagerSlidingTabStrip.setTextColor(getResources().getColor(R.color.bnc_white_transparency)); pagerSlidingTabStrip.setViewPager(viewPager); try { if (getIntent().getExtras().getBoolean("wishlist")) { floatingActionButton.setTranslationY( getResources().getDimensionPixelSize(R.dimen.bnc_button_height)); viewPager.setCurrentItem(1); } } catch (Exception e) { } pagerSlidingTabStrip.setOnPageChangeListener(this); }
public void setToolbarTranslation(View firstChild) { if (firstChild.getTop() > pagerSlidingTabStrip.getHeight()) { appBarLayout .animate() .translationY(0) .setDuration(TRANSLATION_DURATION) .setInterpolator(new DecelerateInterpolator()); } else { scrollToolbarAfterTouchEnds(); } }