5

I'd like to warp a TextView with an arc shape. I know it's possible to warp images, but is it possible to warp TextViews? Is there a established pattern for doing so?

My other option is to warp the text in Photoshop, save it with a transparent background, and use an ImageView, but a client wants this done in about 10 places and I'd like to avoid the extra resources if I can.

warped text

Kyle Clegg
  • 38,547
  • 26
  • 130
  • 141

2 Answers2

3

You need to use customView, override the onDraw(), create a path and use drawTextOnPath.

@Override onDraw(Canvas canvas){
    Path mPath = new Path();
    mPath.addCircle(x, y, 200, Path.Direction.CW);
    canvas.drawTextOnPath(textToDraw, mPath, textX, textY, paint);
}

Please have a look Draw text in circular view?

How to Show Circular Text using TextView in Android

Community
  • 1
  • 1
Yauraw Gadav
  • 1,706
  • 1
  • 18
  • 39
2

Views in Android are rectangular so you'll have to use Canvas and Paint to achieve your goal. Take a look at API Demos in the SDK samples. There is one entry called Graphics/Text Align which shows text drawn along a curving path.

cmak
  • 576
  • 1
  • 4
  • 15
Morrison Chang
  • 11,691
  • 3
  • 41
  • 77