如何制作这种类型的可绘制形状,android?

时间:2014-03-04 06:22:19

标签: android xml drawable shape

我需要使用形状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>

2 个答案:

答案 0 :(得分: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 :(得分:1)

<corners>

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