Loading...

How to Add Border to Android ImageView

ImageView allow you to display images in android application. By default, android doesn’t allow you to add border color in ImageView, but you can add border color according to your wish by using drawable file. So, in this tutorial I will show how to add border color to android ImageView.

Related:
How to Make Rounded Corners(Boarder Radius) of ImageView in Android
How to Rotate an Image in Android
Android Material Design with Design Support Library

Android Example: Adding Border Color to Android ImageView


Drawable Resource File
Create a new drawable file called image_border.xml in your res/drawable/ directory and add following content.
res/drawable/image_border.xml

XML Layout File
Following is the simple android xml layout with a LinearLayout and an ImageView.
res/layout/activity_main.xml

Java Activity File
Following is the default content of MainActivity.java file.
src/MainActivity.java

Following is the default content of strings.xml file.
res/values/strings.xml

Output:

How to Add Border to Android ImageView
Android ImageView Border Color

XML 4257378864283875246
Home item