diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactDrawableHelper.java b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactDrawableHelper.java index add5f38812b..7d93ea2f0ab 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactDrawableHelper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactDrawableHelper.java @@ -17,6 +17,7 @@ import android.graphics.drawable.RippleDrawable; import android.os.Build; import android.util.TypedValue; import androidx.annotation.Nullable; + import com.facebook.react.bridge.JSApplicationIllegalArgumentException; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.SoftAssertions; @@ -37,15 +38,10 @@ public class ReactDrawableHelper { String type = drawableDescriptionDict.getString("type"); if ("ThemeAttrAndroid".equals(type)) { String attr = drawableDescriptionDict.getString("attribute"); - SoftAssertions.assertNotNull(attr); - int attrID = context.getResources().getIdentifier(attr, "attr", "android"); - if (attrID == 0) { + int attrId = getAttrId(context, attr); + if (!context.getTheme().resolveAttribute(attrId, sResolveOutValue, true)) { throw new JSApplicationIllegalArgumentException( - "Attribute " + attr + " couldn't be found in the resource list"); - } - if (!context.getTheme().resolveAttribute(attrID, sResolveOutValue, true)) { - throw new JSApplicationIllegalArgumentException( - "Attribute " + attr + " couldn't be resolved into a drawable"); + "Attribute " + attr + " with id " + attrId + " couldn't be resolved into a drawable"); } Drawable drawable = getDefaultThemeDrawable(context); return setRadius(drawableDescriptionDict, drawable); @@ -57,6 +53,18 @@ public class ReactDrawableHelper { } } + @TargetApi(Build.VERSION_CODES.LOLLIPOP) + private static int getAttrId(Context context, String attr) { + SoftAssertions.assertNotNull(attr); + if ("selectableItemBackground".equals(attr)) { + return android.R.attr.selectableItemBackground; + } else if ("selectableItemBackgroundBorderless".equals(attr)) { + return android.R.attr.selectableItemBackgroundBorderless; + } else { + return context.getResources().getIdentifier(attr, "attr", "android"); + } + } + private static Drawable getDefaultThemeDrawable(Context context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { return context.getResources().getDrawable(sResolveOutValue.resourceId, context.getTheme());