14

I want to have an ImageView with top right corner & bottom left corner rounded.

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

Tried the above code , but it's not working.Please help!

Iulia Barbu
  • 1,522
  • 12
  • 25
vaibvorld
  • 389
  • 2
  • 6
  • 20

2 Answers2

5
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="@android:color/darker_gray"/>
<corners android:topRightRadius="10dp"
    android:bottomRightRadius="0dp"
    android:topLeftRadius="0dp"
    android:bottomLeftRadius="10dp"/>

</shape>

This is my drawable shape.xml in drawable folder. And I am using this drawable to set imageviews background.

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/ic_launcher"
    android:background="@drawable/shape"/>

Done It will appear when you run app on device/emulator (Wont appear in xml graphical layout)

Rohit
  • 2,538
  • 6
  • 28
  • 41
2

I am using this it works fine for me

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

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

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

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

    </shape>
Ashwani Tyagi
  • 510
  • 1
  • 5
  • 15