My app uses GradientDrawable. I have to get colors from GradientDrawable and set it as a background.
private int[] getGradientColors(GradientDrawable drawable) {
// So I have to add this check, cause getColors() method requires min API 24 or higher
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.N)
return drawable;
return Objects.requireNonNull(drawable).getColors();
}
Is there any alternative way to get this colors in API 23?
As I understand you want to set gradient as your layout background.
Adding this line to parent layout will set background as gradient
OR
Through code