Last active
August 14, 2020 17:16
-
-
Save yuriyskulskiy/b383c90432ae06b5bab0e0c30508f70c to your computer and use it in GitHub Desktop.
AnimatedLayout_part_2 exclude from screenshot and clipping
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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