Skip to content

Commit

Permalink
[AppBarLayout] Add setLiftableOverrideEnabled() method to allow toggl…
Browse files Browse the repository at this point in the history
…ing between automatic and manual setLifted() behavior

PiperOrigin-RevId: 388786221
  • Loading branch information
dsn5ft committed Aug 5, 2021
1 parent 67f9e9d commit e2c911b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/java/com/google/android/material/appbar/AppBarLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,21 @@ public boolean setLiftable(boolean liftable) {
return setLiftableState(liftable);
}

/**
* Sets whether the {@link AppBarLayout} lifted state corresponding to {@link
* #setLiftable(boolean)} and {@link #setLifted(boolean)} will be overridden manually.
*
* <p>If true, this means that the {@link AppBarLayout} will not manage its own lifted state and
* it should instead be manually updated via {@link #setLifted(boolean)}. If false, the {@link
* AppBarLayout} will manage its lifted state based on the scrolling sibling view.
*
* <p>Note that calling {@link #setLiftable(boolean)} will result in this liftable override being
* enabled and set to true by default.
*/
public void setLiftableOverrideEnabled(boolean enabled) {
this.liftableOverride = enabled;
}

// Internal helper method that updates liftable state without enabling the override.
private boolean setLiftableState(boolean liftable) {
if (this.liftable != liftable) {
Expand Down

0 comments on commit e2c911b

Please sign in to comment.