Created
December 24, 2014 04:32
-
-
Save ountzza/cb4c981fff50ba690f40 to your computer and use it in GitHub Desktop.
Android CustomView Template
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 CustomView extends View { | |
public CustomView(Context context) { | |
super(context); | |
init(); | |
} | |
public CustomView(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
init(); | |
} | |
public CustomView(Context context, AttributeSet attrs, int defStyleAttr) { | |
super(context, attrs, defStyleAttr); | |
init(); | |
} | |
private void init(){ | |
setWillNotDraw(false); | |
} | |
protected void onDraw(Canvas canvas){ | |
super.onDraw(canvas); | |
Paint p = new Paint(); | |
p.setColor(0xffff0000); | |
canvas.drawLine(0 ,0 ,getMeasuredHeight(),getMeasuredWidth(),p); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment