6

I want to put rounded corners and border to an ImageView, with custom border color. Also, I would like to achieve a glowing effect with the color of the border. Attached sample image. Note that the source image has square borders. I suppose this is achievable only by using Canvas? Any ideas and sample code?

enter image description here

1
  • 1
    If you have already the background (the image with rounded border) add it as background to the ImageView, then use src to set the imageview's content
    – Blackbelt
    Dec 3, 2012 at 14:27

3 Answers 3

1

this is what i have done for my ImageView to make same changes as you want.

made one image_shape.xml

    <?xml version="1.0" encoding="UTF-8"?>
<shape 
    xmlns:android="http://schemas.android.com/apk/res/android">
    <stroke 
        android:width="1dp" 
        />
    <corners 
        android:radius="50dp" />

    <padding 
        android:left="10dp"
        android:right="10dp"
        android:top="10dp"
        android:bottom="10dp"/>


    <solid android:color="#10151D"/>

</shape>

Now, put this xml as the background of your imageView then you will get effect as you want. Right now i have set my own color. you can put your desire color and get effect as rounded glow border effect.

1
  • 2
    Thanks for the effort, but this is not what I want. This only creates rounded corners but not rounded ImageView, also it doesn't have the glow effect. Dec 4, 2012 at 15:53
0

try using the following code in a new xml file named roundCorners in your drawable folder:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<solid android:color="#000000" />

<stroke
    android:width="1dp"
    android:color="#DDDDDD" />

<corners
    android:bottomLeftRadius="2dp"
    android:bottomRightRadius="2dp"
    android:topLeftRadius="2dp"
    android:topRightRadius="2dp" />

</shape>

And then set it as a background to your ImageView in the layout file by:

android:background="@drawable/roundCorners"
0
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle"
    android:thickness="0dp" >
    <stroke android:color="#ff5febe7" android:width="2dp" />
    <solid android:color="#601E3232"/>
    <corners android:radius="5dp" />
</shape>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.