Skip to content

Commit e2c911b

Browse files
committed
[AppBarLayout] Add setLiftableOverrideEnabled() method to allow toggling between automatic and manual setLifted() behavior
PiperOrigin-RevId: 388786221
1 parent 67f9e9d commit e2c911b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,21 @@ public boolean setLiftable(boolean liftable) {
841841
return setLiftableState(liftable);
842842
}
843843

844+
/**
845+
* Sets whether the {@link AppBarLayout} lifted state corresponding to {@link
846+
* #setLiftable(boolean)} and {@link #setLifted(boolean)} will be overridden manually.
847+
*
848+
* <p>If true, this means that the {@link AppBarLayout} will not manage its own lifted state and
849+
* it should instead be manually updated via {@link #setLifted(boolean)}. If false, the {@link
850+
* AppBarLayout} will manage its lifted state based on the scrolling sibling view.
851+
*
852+
* <p>Note that calling {@link #setLiftable(boolean)} will result in this liftable override being
853+
* enabled and set to true by default.
854+
*/
855+
public void setLiftableOverrideEnabled(boolean enabled) {
856+
this.liftableOverride = enabled;
857+
}
858+
844859
// Internal helper method that updates liftable state without enabling the override.
845860
private boolean setLiftableState(boolean liftable) {
846861
if (this.liftable != liftable) {

0 commit comments

Comments
 (0)