开发者

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!
开发者_Python百科UnsupportedOperationException: null

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


Just leave one option:

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


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>


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)


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜