I\'m just trying to implement a color picker for my android application, and ran into a strange issue on Android 4.1.1. The following code does not create the expected gradi
Found the problem: Seems that it has to do with the hardware acceleration. As described here 'ComposeShader
can only contain shaders of different types (a BitmapShader and a LinearGradient for instance, but not two instances of BitmapShader)'. But, 'If your application is affected by any of these missing features or limitations, you can turn off hardware acceleration for just the affected portion of your application by calling setLayerType(View.LAYER_TYPE_SOFTWARE, null)
.'
I saw, that this method is available since SDK 11. My App supports all versions starting with SDK 7, so I have to check if the method is available:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
Now everything's fine.