Android enables camera shooting, selection and image clipping
Some recent learning experiences:
Function realization: after clicking the round avatar, you can upload the album or turn on the camera, then cut the obtained picture, and set the cut picture as the background picture of the avatar
Step 1: customize a class, inherit ImageView, and override the draw method to achieve a circular appearance
Step 2: reference the control in the XML file
Step 3: realize the click event of the round avatar. After clicking, the dialog box interface will be displayed to ask whether you want to open the album or the camera (the code for displaying the dialog box will be omitted automatically)
Step 4: open the album or camera according to the user's selection
Step 5: clip the pictures taken or the pictures selected in the album, and save the results in the specified memory area
Step 6: update the avatar picture
Specific implementation:
Step 1: customize a class, inherit ImageView, and override the draw method to achieve a circular appearance
Step 2: reference the control in the XML file
Step 3: realize the click event of the round avatar. After clicking, the dialog box interface will be displayed to ask whether you want to open the album or the camera (the code for displaying the dialog box will be omitted automatically)
Step 4: open the album or camera according to the user's selection
Step 5: clip the pictures taken or the pictures selected in the album, and save the results in the specified memory area
Step 6: update the avatar picture
Note: you need to add permissions
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.