12 Feb 2021

How To Create Costom View Component in Android?

In this post I am going to share with an interesting thing that might help you learn core concept in Android Development.

android.view.View class is a block building for all of components you see in android. View is a Block Rect area where content are shown. Users interact with app.

Exactly, All widget component ( TextView, Button, ImageView etc) extend android.view.View class.

Creating CostomView Component in Android.

To create Costom View, extend android.view.View class. Overide parent's Public Constructor & Call super() .

Now it is time to draw something on Costom view, @Overide protected method onDraw(android.graphic.Canvas). onDraw() method draw background.

class CostomView extend View { 

public CostomView (Context context){ 


protected void onDraw(Canvas canvas){ 



Drawing on blank CostomView

As an example, I am drawing circle over my Own Costom View.


No comments:

No Comments