2014-03-04 53 views
3

我需要使用形状XML如何使这种类型的可绘制形状,android?

enter image description here

形状必须与在左上和右上圆角而底部的角落,因为它是长方形形状,使这种形状的机器人。

我尝试以下,但不工作

<?xml version="1.0" encoding="utf-8"?> 
    <shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle" > 
    <corners 
    android:topLeftRadius="10dp" 
    android:topRightRadius="10dp" 
     /> 
    <gradient 
    android:angle="270" 
    android:endColor="@color/Red" 
    android:startColor="@color/Red" 
    android:type="linear" /> 
    </shape> 

回答

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

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

    <corners 
     android:topLeftRadius="4dp" 
     android:topRightRadius="4dp" /> 

    <padding 
     android:bottom="5dip" 
     android:left="10dip" 
     android:right="10dip" 
     android:top="5dip" /> 

</shape> 
1

设置<corners>XML

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