Save layout as picture instance code in Android

1、 Foreword

A friend asked if he had done the small function of screenshot, but he didn't do it himself. But think about the implementation process. The purpose of screenshot is to capture part of the layout in our application, and then save it locally, share it, or share it through a third-party platform. I may be influenced by the word screenshot and take it for granted to sort out my implementation ideas.

1: Screen capture: call the screen capture function area of the system to realize screen capture.

2: Process the picture: the screenshot is the full screen of the intercepted mobile phone. Because we need to intercept a part of our application, we need to cut out the part we want to keep (that is, save the layout).

3: Later, you may have to deal with the system screenshot function itself, all sharing and other functions. There will be all kinds of problems anyway.

There is a word above that is "save layout". It means to save our layout as a picture. After hearing this, the first thing I do in the company today is to realize the so-called screen capture function.

2、 Implementation process and implementation code

0: set permissions

1: Get layout

2: Set layout related settings

3. Get pictures

4: Save picture

5: Release resources

6. The complete code is as follows

3、 Summary

Obviously, if we use the method of saving the layout to solve this problem, even if we do it for the first time, it will take less than 30 minutes. If we use the scheme of calling the system screenshot to solve it, it is also the first time. It is estimated that one day is also very dangerous. At the same time, there will be many unknown problems and limitations.

Although this problem is very small, it really makes me feel a lot. Feeling is that we must define our own problems before we solve them. Take this question, if this question is asked in another way. Save the layout instead of screenshots. It is estimated that each of us can think of the above solutions. So when we define a problem, we must fully understand what's going on. Although it can also solve the problem, there may be some phenomena of killing chickens with ox knives. The definition of the problem is digital to analog conversion.

The second is to deal with the problem. We must make several different pre selection records, so as to choose a mouth suitable for ourselves to deal with the problem.

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.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>