Android_Graphics_Canvas
Android_Graphics_Canvas
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawCircle(200, 200, 100, paint);
}
}
paint.setShadowLayer(10, 5, 5, Color.BLACK);
canvas.drawText("Hello, Shadow!", 100, 200, paint);
3. Using Gradients
Gradients allow smooth color transitions. You can use the Shader class with
LinearGradient, RadialGradient, or SweepGradient.
<com.example.CustomView
android:layout_width="match_parent"
android:layout_height="match_parent"/>
Conclusion
Using Canvas, Paint, and Shader, you can create rich custom graphics in Android.
Whether it's simple shapes, shadows, or complex gradients, these APIs provide full control over UI
design.