Skip to content

Commit 1df3a6a

Browse files
cketchamgsajith
authored andcommitted
Update BottomAppBar to reposition the FAB when the vertical offset is changed
PiperOrigin-RevId: 245446154
1 parent fc109fa commit 1df3a6a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/java/com/google/android/material/bottomappbar/BottomAppBar.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ public class BottomAppBar extends Toolbar implements AttachedBehavior {
144144
public @interface FabAnimationMode {}
145145

146146
private final int fabOffsetEndMode;
147-
private final int fabVerticalOffset;
148147
private final MaterialShapeDrawable materialShapeDrawable = new MaterialShapeDrawable();
149148

150149
@Nullable private Animator modeAnimator;
@@ -235,7 +234,7 @@ public BottomAppBar(Context context, @Nullable AttributeSet attrs, int defStyleA
235234
float fabCradleMargin = a.getDimensionPixelOffset(R.styleable.BottomAppBar_fabCradleMargin, 0);
236235
float fabCornerRadius =
237236
a.getDimensionPixelOffset(R.styleable.BottomAppBar_fabCradleRoundedCornerRadius, 0);
238-
fabVerticalOffset =
237+
float fabVerticalOffset =
239238
a.getDimensionPixelOffset(R.styleable.BottomAppBar_fabCradleVerticalOffset, 0);
240239
fabAlignmentMode =
241240
a.getInt(R.styleable.BottomAppBar_fabAlignmentMode, FAB_ALIGNMENT_MODE_CENTER);
@@ -360,6 +359,7 @@ public void setCradleVerticalOffset(@Dimension float verticalOffset) {
360359
if (verticalOffset != getCradleVerticalOffset()) {
361360
getTopEdgeTreatment().setCradleVerticalOffset(verticalOffset);
362361
materialShapeDrawable.invalidateSelf();
362+
setCutoutState();
363363
}
364364
}
365365

@@ -633,7 +633,7 @@ public void onAnimationEnd(Animator animation) {
633633
}
634634

635635
private float getFabTranslationY() {
636-
return -fabVerticalOffset;
636+
return -getTopEdgeTreatment().getCradleVerticalOffset();
637637
}
638638

639639
private float getFabTranslationX(@FabAlignmentMode int fabAlignmentMode) {

0 commit comments

Comments
 (0)