Skip to content

Commit 67f9e9d

Browse files
committed
[AppBarLayout] Updated setLifted() to preserve lifted state if using setLiftable() programmatically
PiperOrigin-RevId: 388539565
1 parent 9fb73b5 commit 67f9e9d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/java/com/google/android/material/appbar/AppBarLayout.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -857,17 +857,21 @@ private boolean setLiftableState(boolean liftable) {
857857
* @return true if the lifted state changed
858858
*/
859859
public boolean setLifted(boolean lifted) {
860-
return setLiftedState(lifted);
860+
return setLiftedState(lifted, /* force= */ true);
861861
}
862862

863863
/** Returns whether the {@link AppBarLayout} is in a lifted state or not. */
864864
public boolean isLifted() {
865865
return lifted;
866866
}
867867

868-
// Internal helper method that updates lifted state.
869868
boolean setLiftedState(boolean lifted) {
870-
if (this.lifted != lifted) {
869+
return setLiftedState(lifted, /* force= */ !liftableOverride);
870+
}
871+
872+
// Internal helper method that updates lifted state.
873+
boolean setLiftedState(boolean lifted, boolean force) {
874+
if (force && this.lifted != lifted) {
871875
this.lifted = lifted;
872876
refreshDrawableState();
873877
if (liftOnScroll && getBackground() instanceof MaterialShapeDrawable) {

0 commit comments

Comments
 (0)