view in xml layout



I've created my own view and I can't figure out how to add it from the main.xml layout file


setContentView(vi); its work but ı want setContentView(R.layout.activity_main);


public class Gui extends View {



public Gui(Context context) {
super(context);

}
@Override
protected void onDraw(Canvas canvas) {


Paint myPaint = new Paint();
Paint myPaintFill= new Paint();


myPaintFill.setColor(Color.GREEN);

myPaint.setColor(Color.BLACK);
myPaint.setStyle(Paint.Style.STROKE);
myPaint.setStrokeWidth(1);


RectF r = new RectF(0,0,50,50);
canvas.drawRoundRect(r, 0, 0, myPaint);



}

}


}


No comments:

Post a Comment