Can't Repro
Status Update
Comments
al...@android.com <al...@android.com>
ch...@google.com <ch...@google.com>
ki...@google.com <ki...@google.com> #3
Thanks for the report!
ki...@google.com <ki...@google.com> #4
The release notes documentation has been edited to clarify this change in behavior for line height.
To support non-standard text sizes, we encourage users to follow the Material design system and use a different style = LocalTextStyle.current.copy(lineHeight = TextUnit.Unspecified)
, or create a custom Typography
entirely.
Description
In the end i have found that the strange behaviour is caused by the mutate issue of Transition/LayerDrawable that has been fixed on api level 18.
This is the code that i'm using to solve the problem:
private static Drawable getDrawableCompat(Resources res, int id) {
Drawable d = ResourcesCompat.getDrawable(res, id, null);
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN_MR1) {
// fix for "TransitionDrawable should not become a LayerDrawable"
//
// issue fixed on api 18+ (mr2) and that happens only on api 17 (mr1) because of the different
// drawable constantstate/mutate handling added on api 17
// "The drawables cache strikes again"
//
if (hasLayerDrawable(d)) {
d = d.getConstantState().newDrawable();
}
}
return d;
}
public static boolean hasLayerDrawable(Drawable d) {
if (d instanceof LayerDrawable) {
return true;
} else if (d instanceof DrawableContainer) {
final DrawableContainer.DrawableContainerState cs = (DrawableContainer.DrawableContainerState)d.getConstantState();
final Drawable[] children = cs.getChildren();
if (children != null) {
for (Drawable child : cs.getChildren()) {
if (child != null) {
if (hasLayerDrawable(child)) return true;
}
}
}
}
return false;
}