Skip to content

Instantly share code, notes, and snippets.

@yuriyskulskiy
Last active August 14, 2020 17:16
Show Gist options
  • Save yuriyskulskiy/b383c90432ae06b5bab0e0c30508f70c to your computer and use it in GitHub Desktop.
Save yuriyskulskiy/b383c90432ae06b5bab0e0c30508f70c to your computer and use it in GitHub Desktop.
AnimatedLayout_part_2 exclude from screenshot and clipping
public class AnimatedLayout extends ConstraintLayout {
...
@Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
if (canvas instanceof ScreenShotCanvas) {
if (isChildExcluded(child)) {
// do not draw this child to the screenshot canvas
return false;
}
return super.drawChild(canvas, child, drawingTime);
}
if (mCurrentAnimation != IDLE_ANIMATION_STATE) {
if (isChildExcluded(child)) {
// don't clip to rectangle this child view
return super.drawChild(canvas, child, drawingTime);
}
canvas.save();
clipToRectangle(canvas, child);
boolean result = super.drawChild(canvas, child, drawingTime);
canvas.restore();
return result;
} else {
return super.drawChild(canvas, child, drawingTime);
}
}
private boolean isChildExcluded(View child) {
return child.getId() == R.id.weatherIconIV;
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment