Raiv
Raiv

Reputation: 5781

How can I make rounded only one edge of the rectangle?

I have the following code:

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
       <stroke android:color="@color/conversation_border" android:width="1dp"/>
       <solid android:color="@color/conversation_is_user_bg"/>
            <corners android:radius="1dp" />
            <padding android:left="7dp" android:top="1dp" android:right="1dp" android:bottom="7dp"/>  
</shape>

When i apply it to TextView, all is OK. but when i replace

<corners android:radius="1dp" />

with

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

I have anexception. I already tried not to remove android:radius attribute, provide radius in px and dp, and result is always

error!
UnsupportedOperationException: null

which is very descriptive. What am I doing wrong and how to round only bottom left corner of the text view?

Upvotes: 2

Views: 426

Answers (4)

Raiv
Raiv

Reputation: 5781

That was a bug in android emulator, thanks to all who answered. After updating emulator to latest version all is working without modifications (exept this bug , but there is walkaround for it)

Upvotes: 1

ilango j
ilango j

Reputation: 6037

try with below code:

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

    <corners android:bottomLeftRadius="8dip"
        android:topLeftRadius="1dip" android:bottomRightRadius="1dip"
        android:topRightRadius="1dip" />

</shape>

Upvotes: 0

Niranj Patel
Niranj Patel

Reputation: 33238

try this one...

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/corners_blue_random">
    <solid android:color="@color/conversation_is_user_bg" />
    <corners android:radius="1dip" android:bottomLeftRadius="8dip"
        android:topLeftRadius="1dip" android:bottomRightRadius="1dip"
        android:topRightRadius="1dip" />
    <stroke android:color="@color/conversation_border"
        android:width="1dp" />
</shape>

Upvotes: 1

pawelzieba
pawelzieba

Reputation: 16082

Just leave one option:

<corners 
    android:bottomLeftRadius="8dp"
/>

Upvotes: 1

Related Questions