@@ -284,8 +284,8 @@ public AppBarLayout(@NonNull Context context, @Nullable AttributeSet attrs, int
284
284
if (a .hasValue (R .styleable .AppBarLayout_expanded )) {
285
285
setExpanded (
286
286
a .getBoolean (R .styleable .AppBarLayout_expanded , false ),
287
- /* animate */ false ,
288
- /* force */ false );
287
+ /* animate= */ false ,
288
+ /* force= */ false );
289
289
}
290
290
291
291
if (VERSION .SDK_INT >= 21 && a .hasValue (R .styleable .AppBarLayout_elevation )) {
@@ -677,6 +677,15 @@ public CoordinatorLayout.Behavior<AppBarLayout> getBehavior() {
677
677
return behavior ;
678
678
}
679
679
680
+ @ Nullable
681
+ public MaterialShapeDrawable getMaterialShapeBackground () {
682
+ Drawable background = getBackground ();
683
+ if (background instanceof LayerDrawable ) {
684
+ background = ((LayerDrawable ) background ).getDrawable (0 );
685
+ }
686
+ return background instanceof MaterialShapeDrawable ? (MaterialShapeDrawable ) background : null ;
687
+ }
688
+
680
689
@ RequiresApi (VERSION_CODES .LOLLIPOP )
681
690
@ Override
682
691
public void setElevation (float elevation ) {
@@ -1035,11 +1044,12 @@ boolean setLiftedState(boolean lifted, boolean force) {
1035
1044
}
1036
1045
1037
1046
private boolean isLiftOnScrollCompatibleBackground () {
1038
- if (getBackground () instanceof MaterialShapeDrawable ) {
1047
+ Drawable background = getBackground ();
1048
+ if (background instanceof MaterialShapeDrawable ) {
1039
1049
return true ;
1040
1050
}
1041
- if (getBackground () instanceof LayerDrawable ) {
1042
- LayerDrawable layerBackground = (LayerDrawable ) getBackground () ;
1051
+ if (background instanceof LayerDrawable ) {
1052
+ LayerDrawable layerBackground = (LayerDrawable ) background ;
1043
1053
if (layerBackground .getNumberOfLayers () == 2
1044
1054
&& layerBackground .getDrawable (0 ) instanceof MaterialShapeDrawable
1045
1055
&& layerBackground .getDrawable (1 ) instanceof MaterialShapeDrawable ) {
0 commit comments