From d6c435461eece74656db5e2de92944c7ca807439 Mon Sep 17 00:00:00 2001 From: dsn5ft <1420597+dsn5ft@users.noreply.github.com> Date: Tue, 19 Apr 2022 11:50:23 -0400 Subject: [PATCH] [AppBarLayout] Add setLiftOnScrollTargetView() method Resolves https://github.com/material-components/material-components-android/pull/2544 PiperOrigin-RevId: 442823082 --- .../android/material/appbar/AppBarLayout.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/java/com/google/android/material/appbar/AppBarLayout.java b/lib/java/com/google/android/material/appbar/AppBarLayout.java index f775bb5f4f0..da4e04e62de 100644 --- a/lib/java/com/google/android/material/appbar/AppBarLayout.java +++ b/lib/java/com/google/android/material/appbar/AppBarLayout.java @@ -967,6 +967,19 @@ public boolean isLiftOnScroll() { return liftOnScroll; } + /** + * Sets the view that the {@link AppBarLayout} should use to determine whether it should be + * lifted. + */ + public void setLiftOnScrollTargetView(@Nullable View liftOnScrollTargetView) { + this.liftOnScrollTargetViewId = View.NO_ID; + if (liftOnScrollTargetView == null) { + clearLiftOnScrollTargetView(); + } else { + this.liftOnScrollTargetView = new WeakReference<>(liftOnScrollTargetView); + } + } + /** * Sets the id of the view that the {@link AppBarLayout} should use to determine whether it should * be lifted.