Created
August 23, 2018 10:04
-
-
Save maxim-petlyuk/5f4d4eb70ab1cbac9b5af34b2fbb732f to your computer and use it in GitHub Desktop.
Draw view from the existing original view
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 CloneView extends View { | |
private View mSource; | |
public CloneView(Context context) { | |
super(context); | |
} | |
public CloneView(Context context, @Nullable AttributeSet attrs) { | |
super(context, attrs); | |
} | |
public CloneView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { | |
super(context, attrs, defStyleAttr); | |
} | |
public View getSource() { | |
return mSource; | |
} | |
public void setSource(View source) { | |
mSource = source; | |
invalidate(); | |
} | |
@Override | |
protected void onDraw(Canvas canvas) { | |
if (mSource != null) { | |
mSource.draw(canvas); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment