SSD SSD -4 years ago 120
Android Question

Rounded Rectangle shape to image retrieving from server in android

I want to give rounded rectangle shape to the images that I am fetching them from the server and displaying in list view.
Currently I am able to make the images in a rounded rectangle shape which are available in my drawable folder. But finding the difficulties for the images fetching from the server.

Please let me know how can I do this..

Thank You

Answer Source

Round corners to view, simply create xml for drawable, apply Radius rate to your image corner as well as you can apply background color to your view too, check below code and steps.

Create one folder named Drawable within Res, keep below xml in drawable and you can set at runtime or in layout xml to your view.

round_border.xml

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#5a5a5a"/>
<corners android:radius="10px"/>
<padding android:left="20dp" android:top="20dp" android:right="20dp" android:bottom="20dp"/> 
</shape>

Within xml

 android:background="@drawable/round_border"

Jave code

ImageView im=(ImageView)findViewById(R.id.imageView2);
    im.setBackgroundResource(R.drawable.round_border);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download