ImageView in Android using Jetpack Compose
Images, Graphics, and vectors attract so many users as they tell so much information in a very informative way. ImageView in Android is used to display different types of images from drawable or in the form of Bitmaps. In this article, we will take a look at the implementation of an ImageView in Android using Jetpack Compose.
Attributes of ImageView Widget
|imageVector||to add an image from Drawable resource inside our imageview|
|bitmap||to add a bitmap for your image inside imageview.|
|modifier||to add padding to imageview|
|contentScale||to add scaling to our image to fit our image inside imageview|
|alpha||to add alpha to our imageview.|
|colorFilter||to add colors to our imageview.|
|blendMode||to add color effects to our imageview.|
Step by Step Implementation
Step 1: Create a New Project
To create a new project in the Android Studio Canary Version please refer to How to Create a new Project in Android Studio Canary Version with Jetpack Compose.
Step 2: Add an Image to the drawable folder
After creating a new project we have to add an image inside our drawable folder for displaying that image inside our ImageView. Copy your image from your folder’s location and go inside our project. Inside our project Navigate to the app > res > drawable > Right-click on the drawable folder and paste your image there.
Step 3: Working with the MainActivity.kt file
After adding this image navigates to the app > java > MainActivity.kt and add the below code to it. Comments are added inside the code for a detailed explanation.