Last active
January 25, 2018 17:03
-
-
Save mrabelwahed/f36e45ad81aa2886b184535b6b69080c to your computer and use it in GitHub Desktop.
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
package com.ramadan_apps.mylibrary; | |
import android.content.Context; | |
import android.content.res.TypedArray; | |
import android.graphics.Canvas; | |
import android.graphics.Paint; | |
import android.support.annotation.Nullable; | |
import android.util.AttributeSet; | |
import android.view.View; | |
/** | |
* Created by Mahmoud Ramadan on 1/25/18. | |
*/ | |
public class CircleView extends View { | |
private float dim; | |
private String shape; | |
public CircleView(Context context) { | |
super(context); | |
} | |
public CircleView(Context context, @Nullable AttributeSet attrs) { | |
super(context, attrs); | |
init(context,attrs); | |
} | |
private void init(Context context , AttributeSet attrs){ | |
TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs,R.styleable.CircleView,0,0); | |
try { | |
dim = typedArray.getDimension(R.styleable.CircleView_dim,20f); | |
shape = typedArray.getString(R.styleable.CircleView_shape); | |
}finally { | |
typedArray.recycle(); | |
} | |
} | |
@Override | |
protected void onDraw(Canvas canvas) { | |
super.onDraw(canvas); | |
canvas.drawCircle(dim,dim,dim,new Paint()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment