How to rotate TextView without clipping its bounds?

前端 未结 4 1901
南旧
南旧 2021-02-08 10:41

I\'m trying to rotate my subclass of TextView using canvas.rotate():

canvas.save();

final int w = getWidth();
final int h = getHeight(         


        
4条回答
  •  攒了一身酷
    2021-02-08 11:11

    Ok, if you cant rotate textView in your current view hierarch, you should animate it in another one.

    Create a bitmap represantation of your textView. Use a holder for this bitmap like ImageView. Connect the imageView to another layout which is on top and where it won't be cropped. Hide your textView. Run animation on ImageView. When animation finished, update textView representation, show textView and remove ImageView.

    I cant find the exact code example of what you want, but take a look at this one. The interecting place is:

    mWindowManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
    mWindowManager.addView(YOUR_VIEW_WITH_ANIMATION, mWindowParams);
    

提交回复
热议问题