public void testGetColorWithAlpha() {
   assertEquals(
       Color.parseColor("#00123456"),
       ScrollUtils.getColorWithAlpha(0, Color.parseColor("#FF123456")));
   assertEquals(
       Color.parseColor("#FF123456"),
       ScrollUtils.getColorWithAlpha(1, Color.parseColor("#FF123456")));
 }
Exemplo n.º 2
0
  /* TOOLBAR ANIMATIONS */
  private void updateScroll(int scrollY) {
    float alpha =
        Math.min(
            1,
            (float) scrollY / (flexibleSpaceHeight - binding.rlAdvertisementInfo.getHeight() - 25));
    binding.toolbar.setBackgroundColor(ScrollUtils.getColorWithAlpha(alpha, toolbarColor));
    binding.toolbar.setTitleTextColor(ScrollUtils.getColorWithAlpha(alpha, titleColor));

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      detailsView.changeStatusBarColor(ScrollUtils.getColorWithAlpha(alpha / 4, statusBarColor));
    }

    binding.rlAdvertisementInfo.setAlpha(1 - ((float) scrollY / (flexibleSpaceHeight / 3)));
  }
Exemplo n.º 3
0
 @Override
 public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
   int baseColor = getResources().getColor(R.color.Dark);
   float alpha = Math.min(1, (float) scrollY / mParallaxImageHeight);
   mToolbarView.setBackgroundColor(ScrollUtils.getColorWithAlpha(alpha, baseColor));
   ViewHelper.setTranslationY(convenientBanner, scrollY / 2);
 }
Exemplo n.º 4
0
  private void initViews(View itemView) {
    convenientBanner = (ConvenientBanner) itemView.findViewById(R.id.convenientBanner);
    mToolbarView = itemView.findViewById(R.id.toolbar);
    mToolbarView.setBackgroundColor(
        ScrollUtils.getColorWithAlpha(0, getActivity().getResources().getColor(R.color.Dark)));

    mScrollView = (ObservableScrollView) itemView.findViewById(R.id.scroll);
    mScrollView.setScrollViewCallbacks(this);

    mParallaxImageHeight = getResources().getDimensionPixelSize(R.dimen.parallax_image_height);
  }