简体   繁体   中英

Create rectangle shape drawable with two side curved corner in android

I create a shape drawable resource xml file for a create a background with two side curved corner.
Here I post my code of Shape drawable. But it not give me right result. It give me 4 side curved image. So I just wanted to know how to create 2 side curved shape image.

Thanks

<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="#0579CD" />
<corners
    android:bottomLeftRadius="0dp"
    android:bottomRightRadius="0dp"
    android:topLeftRadius="15dp"
    android:topRightRadius="15dp" />
<padding
    android:bottom="8dp"
    android:left="8dp"
    android:right="8dp"
    android:top="8dp" />

Just pass the miner value to non-curve corner field. in your case:

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

And one thing more. the preview are not show in graphical layout. You should try to see in device.
I hope this will help you.

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

you are giving all side radius , so it is giving you the right result. you have to give only two options like:

<corners
    android:topLeftRadius="15dp"
    android:topRightRadius="15dp" 

/>

or any other possible condition.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM