Skip to content

Commit 034e8c5

Browse files
committed
[Internal] Fix drawable compositing on API < 23
1 parent 9da9993 commit 034e8c5

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

lib/java/com/google/android/material/drawable/DrawableUtils.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,9 @@ public static Drawable compositeTwoLayeredDrawable(
241241
* @param bottomLayerDrawable the drawable to be on the bottom layer
242242
* @param topLayerDrawable the drawable to be on the top layer
243243
* @param topLayerDesiredWidth top layer desired width in pixels, or {@link #INTRINSIC_SIZE} to
244-
* use the intrinsic width.
244+
* use the intrinsic width as the desired one.
245245
* @param topLayerDesiredHeight top layer desired height in pixels, or {@link #INTRINSIC_SIZE} to
246-
* use the intrinsic height.
246+
* use the intrinsic height as the desired one.
247247
*/
248248
@Nullable
249249
public static Drawable compositeTwoLayeredDrawable(
@@ -258,8 +258,6 @@ public static Drawable compositeTwoLayeredDrawable(
258258
return bottomLayerDrawable;
259259
}
260260

261-
boolean shouldScaleTopLayer =
262-
topLayerDesiredWidth != INTRINSIC_SIZE && topLayerDesiredHeight != INTRINSIC_SIZE;
263261
if (topLayerDesiredWidth == INTRINSIC_SIZE) {
264262
topLayerDesiredWidth = getTopLayerIntrinsicWidth(bottomLayerDrawable, topLayerDrawable);
265263
}
@@ -300,10 +298,9 @@ public static Drawable compositeTwoLayeredDrawable(
300298
drawable.setLayerSize(1, topLayerNewWidth, topLayerNewHeight);
301299
drawable.setLayerGravity(1, Gravity.CENTER);
302300
} else {
303-
if (shouldScaleTopLayer) {
304-
topLayerDrawable =
305-
new ScaledDrawableWrapper(topLayerDrawable, topLayerNewWidth, topLayerNewHeight);
306-
}
301+
topLayerDrawable =
302+
new ScaledDrawableWrapper(topLayerDrawable, topLayerNewWidth, topLayerNewHeight);
303+
307304
drawable = new LayerDrawable(new Drawable[] {bottomLayerDrawable, topLayerDrawable});
308305

309306
final int horizontalInset =

0 commit comments

Comments
 (0)