Closed sonaypsi closed 7 years ago
@sonaypsi Please show me more detail, such as the layout xml and java code.
I noticed the issue when trying to set a wave color. It tries to recreate the shader, but if you call the method before the view is drawn it will throw the error that person mentioned. I changed the method to look like this and it worked:
public void setWaveColor(int behindWaveColor, int frontWaveColor) {
mBehindWaveColor = behindWaveColor;
mFrontWaveColor = frontWaveColor;
// need to recreate shader when color changed
mWaveShader = null;
if(getWidth() == 0 || getHeight() == 0) {
getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
createShader();
invalidate();
getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
});
}
else {
createShader();
invalidate();
}
}
fixed
java.lang.IllegalArgumentException: width and height must be > 0 in wave annimation