Android adds a full screen tilt watermark to any view
This article mainly introduces Android to add full screen tilt watermark to any view. The details are as follows, which are shared with you
If you want to achieve the following effects
At present, there are two ideas:
1. Draw a picture with horizontal text first, and then combine it with the original picture
2. Rotate the canvas, and then write directly on the canvas
Both schemes are similar. The second scheme explained here.
However, there are problems with both schemes, that is, the text needs to be completely covered, so our canvas needs to be larger than the picture. In fact, just move the canvas to the outer cut of the original picture.
In order to analyze the problem simply, we take the longest edge and treat the original graph as a square. The length of the edge of the circumscribed square is the diagonal edge. As shown below
From the above figure, we can see that we need to rotate 45 degrees and then translate back. The translation distance can be analyzed as the difference between the two sides from the following figure.
The specific code is as follows. The comments are also more detailed, so I won't expand it
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.