Skip to content

Instantly share code, notes, and snippets.

@ountzza
Created December 24, 2014 04:32
Show Gist options
  • Save ountzza/cb4c981fff50ba690f40 to your computer and use it in GitHub Desktop.
Save ountzza/cb4c981fff50ba690f40 to your computer and use it in GitHub Desktop.
Android CustomView Template
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