I want to create imageviews with curved edges like this diagram
I want to be able to change the colours of the border at runtime. How can I achieve this?
I want to create imageviews with curved edges like this diagram
I want to be able to change the colours of the border at runtime. How can I achieve this?
Define the image view as this and give the background the rectangle shape.
<ImageView
android:id="@+id/image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/rectangle"
android:src="@drawable/ic_launcher" />
The rectangle is defined as follows.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@android:color/white" />
<size
android:width="100dp"
android:height="100dp" />
<stroke
android:width="10dp"
android:color="@android:color/black" />
<corners android:radius="50dp"/>
</shape>
Finally, from your code, set the color this way:
ImageView image = (ImageView) findViewById(R.id.image);
GradientDrawable background = (GradientDrawable) image.getBackground();
background.setStroke(10, getResources().getColor(android.R.color.black));