Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OverlapPageTransformer 接受可变 alpha 参数,使 alpha 生效 #305

Open
24suixinsuoyu opened this issue Apr 4, 2023 · 0 comments
Open

Comments

@24suixinsuoyu
Copy link

类 BannerManager 中,重写 setMultiPageStyle() 方法:

public void setMultiPageStyle(boolean overlap, float scale, float alpha) {
    removeDefaultPageTransformer();
    if (overlap && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      mDefaultPageTransformer = new OverlapPageTransformer(mBannerOptions
          .getOrientation(), scale, 0f, alpha, 0);
    } else {
      mDefaultPageTransformer = new ScaleInTransformer(scale);
    }
    mCompositePageTransformer.addTransformer(mDefaultPageTransformer);
  }

类 OverlapPageTransformer 中,重写 transformPage() 方法的 alpha 部分:

if (unSelectedItemAlpha != 1f) {
        alpha = when {
          position < 0 -> {
            abs((1 - unSelectedItemAlpha) * position + 1)
          }
          else -> {
            abs((unSelectedItemAlpha - 1) * position + 1)
          }
        }
      }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant