SoFunction
Updated on 2025-03-11

Android UI development View self-drawing control Share


public class cwjView extendsView

{

public cwjView(Context context)

{

this(context,null);

}

public cwjView(Context context,AttributeSet attrs)

{

this(context,attrs,0);

}

public cwjView(Context context,AttributeSet attrs,int defStyle)

{

super(context,attrs,defStyle);

//This is the construction of this class. You can add code here for the relevant initialization.

}

@Override

protectd void onDraw(Canvas canvas)

{

super(canvas);

//The key to drawing, you can see that a canvas handle has been included, which can be directly used to perform related operations through the Canvas class we mentioned earlier. For a complete example, you can refer to the implementation of the Snake Snake game in the Android SDK.

}

}