Underlined text on Android Canvas
2 answers
You can use Paint. UNDERLINE_TEXT_FLAG ,
Example:
class SampleView extends View {
public SampleView(Context context) {
super(context);
}
@Override
protected void onDraw(Canvas canvas) {
Paint paint = new Paint();
paint.setTextSize(25);
paint.setColor(Color.RED);
paint.setFlags(Paint. UNDERLINE_TEXT_FLAG);
paint.setColor(Color.GREEN);
canvas.drawText("My Underline Text", 50, 140, paint);
}
}
+3
source to share