In, this post we're going to make an app that captures or selects an image and then displays in an image view using a third party library - android image cropper by ArthurHub at Github.
Step 1: Add Dependency :
Open android studio and paste this dependency in app-level build.gradle file as shown below:
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.+'
and then click on Sync Now.
Step 2: Design the main activity layout :
Add a Button and an ImageView to select and display image respectively as shown below:
Step 3: Modify AndroidMainfest.xml by adding the CropImageActivity :
<activity
android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
android:screenOrientation="portrait"
android:theme="@style/Base.Theme.AppCompat"/>
as shown below-
Step 4: Open CropImageActivity on Click of a button :
Step 5: Lastly, override the On Activity Result and update ImageView :
Now, run the app :)
You will output something like this:
The source code of this image picker app is available at GitHub.
If you face any problem or have any suggestion please comment it down we love to answer it.
Open android studio and paste this dependency in app-level build.gradle file as shown below:
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.+'
and then click on Sync Now.
Step 2: Design the main activity layout :
Add a Button and an ImageView to select and display image respectively as shown below:
Step 3: Modify AndroidMainfest.xml by adding the CropImageActivity :
<activity
android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
android:screenOrientation="portrait"
android:theme="@style/Base.Theme.AppCompat"/>
as shown below-
Step 4: Open CropImageActivity on Click of a button :
Now, run the app :)
You will output something like this:
The source code of this image picker app is available at GitHub.
If you face any problem or have any suggestion please comment it down we love to answer it.
Comment down what next topic you need a guide on? or Drop a message on our social media handle.
Happy coding and designing : )
Comments
Post a Comment