How to Implement ColoredShadowImageView Library in Android?
Last Updated :
13 Jan, 2022
Android is an open-source operating system, based on the Linux kernel and used in mobile devices like smartphones, tablets, etc. Further, it was developed for smartwatches and Android TV. Each of them has a specialized interface. Android has been one of the best-selling OS for smartphones. Android OS was developed by Android Inc. which Google bought in 2005. In this article, we are going to implement the ColoredShadowImageView library. While showing an image if we want to add shadow then we do that by creating a file in drawable and then after adding component in that we are able to show the shadow. Here we are going to show shadows in an image using the library.
Step By Step Implementation
Step 1: Create a New Project
To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. Note that select Java as the programming language.
Step 2: Add this into the build.gradle file
implementation 'com.github.armcha:ColoredShadowImageView:1.1.0'
You also need to add RenderScript to your app module. Add these lines to the defaultConfig block of your build.gradle.
renderscriptTargetApi YOUR_TARGET_SDK_VERSION
renderscriptSupportModeEnabled true
Step 3: Working with the activity_main.xml file
Go to the activity_main.xml file and refer to the following code. Below is the code for the activity_main.xml file.
XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
tools:context=".ColorShadow">
<!--adding shadowimageview library-->
<io.github.armcha.coloredshadow.ShadowImageView
android:id="@+id/shadowImage"
android:layout_width="250dp"
android:layout_height="250dp"
android:src="@drawable/circle"/>
</LinearLayout>
 Â
Step 4: Working with the MainActivity.java file
Â
Go to the MainActivity.java file and refer to the following code. Below is the code for the MainActivity.java fileÂ
Â
Java
import androidx.appcompat.app.AppCompatActivity;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.ViewTarget;
import io.github.armcha.coloredshadow.ShadowImageView;
public class ColorShadow extends AppCompatActivity {
ShadowImageView imageViewl;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_color_shadow);
imageViewl=findViewById(R.id.shadowImage);
// showing image using Glide Library
Glide.with(ColorShadow.this).load(R.drawable.circle)
// adding it as placeholder if loading gets null
.placeholder(R.drawable.circle)
.into(imageViewl);
}
}
 Â
Output:
Â
Â
Similar Reads
How to Implement Shapeable ImageView in Android? In Android, ShapeableImageView is used to change the shape of your image to circle, diamond, etc. Also, you can set a corner radius to your ImageView. You can do much more by using this ShapeableImageView with minimal code. So in this article, we are going to make a ShapableImageView in android. By
5 min read
How to Implement TNImage Library in Android? Android is an open-source operating system, based on the Linux kernel and used in mobile devices like smartphones, tablets, etc. Further, it was developed for smartwatches and Android TV. Each of them has a specialized interface. Android has been one of the best-selling OS for smartphones. Android O
3 min read
How to Implement Glassmorphism in Android? Glassmorphism or BlurView is a style, developed by adopting the behavior of glass to enhance your app design. It gives a look and feel of translucent or transparent elements. Glassmorphic elements and shapes work really well on bright colorful backgrounds which accentuate the glass effect. So, we wi
2 min read
How to implement Dark (Night) mode in Android app Light-on-dark color scheme, also called dark mode, is a supplemental mode that uses a color scheme in which content of a webpage is displayed on a dark background. Such a color scheme reduces the light emitted by screens and enhances readability. Switching to dark mode allows website users to move t
5 min read
How to Implement ViewPager with Dotsindicator in Android? ViewPager in Android is a class that allows the user to flip left and right through pages of data. This class provides the functionality to flip pages in-app. It is a widget found in the support library. What are Dotsindicator? These are dots that help us to see which view is currently opened when w
4 min read