2

This is my xml layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="75dp"
    android:padding="3dp" >
    <ImageView
        android:id="@+id/img"
        android:layout_width="75dp"
        android:layout_height="75dp"
        android:scaleType="fitCenter" 

        />

    <TextView
        android:id="@+id/name"
        android:layout_width="208dp"
        android:layout_height="75dp"
        android:paddingLeft="15dp"
        android:paddingTop="15dp" />


    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="30dp"
        android:layout_gravity="center"
        android:src="@drawable/ash_arrow" />

</LinearLayout>

How can i show my ImageView with rounded corners?

Praveenkumar
  • 24,084
  • 23
  • 95
  • 173
edi233
  • 3,511
  • 13
  • 56
  • 97

2 Answers2

3

ash_arrow.xml

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">

    <!--Background with solid color-->

    <solid android:color="@color/colorWhite"/>

    <!--background with gradient-->
    <!--<gradient-->
    <!--android:centerColor="#fff"-->
    <!--android:centerX="50%"-->
    <!--android:centerY="50%"-->
    <!--android:endColor="#f0f"-->
    <!--android:gradientRadius="100"-->
    <!--android:startColor="#f00"-->
    <!--android:type="radial"/>-->

    <!--Stoke with dashed line-->
    <!--<stroke-->
    <!--android:width="8dp"-->
    <!--android:color="#f00"-->
    <!--android:dashGap="8dp"-->
    <!--android:dashWidth="8dp"/>-->

    <!--Stroke normal-->
    <stroke
        android:width="1dp"
        android:color="@color/willow_grove"/>

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

</shape>

enter image description here

Aerrow
  • 12,086
  • 10
  • 56
  • 90
  • 2
    how to use this xml ?? – Eman87 Feb 01 '14 at 16:14
  • How does this show an image with rounded corners? Doesn't it simply replace the image? – AmiguelS Jan 31 '17 at 12:07
  • @AmiguelS: use like this -> android:background="@drawable/ash_arrow" and set image Original image android:src="@drawable/ic_launcher" – Aerrow Jan 31 '17 at 12:49
  • @Aerrow Consider editing your answer, because it is currently wrong. – AmiguelS Jan 31 '17 at 16:03
  • @AmiguelS: now its ok? – Aerrow Feb 01 '17 at 05:03
  • @Aerrow I believe it still replaces the original image... – AmiguelS Feb 01 '17 at 10:10
  • @AmiguelS: try with this snipped, you will get the reslut like above. Or you need via java code use Circular Imageview or Some other libraries. Hope the user posted the question need the above result, yours may varies. – Aerrow Feb 01 '17 at 11:54
  • I do not need this answer, I just happened to see it and noticed it was misleading. On your answer you provide ash_arrow.xml, but ash_arrow is the user drawable, so you are replacing it, instead of adding a frame, which is what you are trying to do. – AmiguelS Feb 01 '17 at 12:09
1

What if you try to set a background to your ImageView, defining a Shape in xml that would only contain a "corner" Attribute? Something like that:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >
    <corners android:radius="20dip" />
</shape>
Jeje Doudou
  • 1,707
  • 1
  • 16
  • 24