I would like to design a curved textview in Android that picture is below.
Asked
Active
Viewed 1,667 times
-1
Phantômaxx
- 37,352
- 21
- 80
- 110
Programing World
- 93
- 12
-
Create a custom View .AFAIK its not possible with xml. – ADM Feb 23 '18 at 07:35
-
can i know how could we do this?can we do it from java – Programing World Feb 23 '18 at 07:37
-
@Nilesh Rathod but i would like to do it from xml textview – Programing World Feb 23 '18 at 07:50
1 Answers
-1
this is work on using canvas and draw text and make you custom textview.
public class CustomView extends View{
private static final String MY_TEXT = "Hello World";
private Path mArc;
private Paint mPaintText;
public CustomView(Context context) {
super(context);
mArc = new Path();
RectF oval = new RectF(50,100,200,250);;
mArc.addArc(oval, -180, 200);
mPaintText = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaintText.setStyle(Paint.Style.FILL_AND_STROKE);
mPaintText.setColor(Color.WHITE);
mPaintText.setTextSize(20f);
}
@Override
protected void onDraw(Canvas canvas) {
canvas.drawTextOnPath(MY_TEXT, mArc, 0, 20, mPaintText);
invalidate();
}
}
Mobile Team ADR-Flutter
- 12,062
- 2
- 29
- 49