shape的使用

转载:http://blog.csdn.net/lovexieyuan520/article/details/39188441html


在使用shape做为背景的时候,代码以下:android

[html] view plain copyide

  1. <?xml version="1.0" encoding="utf-8"?>  url

  2. <shape xmlns:android="http://schemas.android.com/apk/res/android" >  spa

  3.     <corners android:topLeftRadius="30dp" android:bottomLeftRadius="30dp"  .net

  4.         android:topRightRadius="0dp" android:bottomRightRadius="0dp"/>  orm

  5.     <solid android:color="#ff0000"/>  xml

  6. </shape>  htm

在android3.0以上显示正常以下:blog



可是在android3.0如下,好比android2.3.3结果以下:


这显然不符合咱们的要去,我想了不少办法都没能解决,只有经过图片背景来实现,但我在stackoverflow看到一方案计较好,记录一下:

代码以下:

[html] view plain copy

  1. <?xml version="1.0" encoding="utf-8"?>  

  2. <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >  

  3.     <item>  

  4.       <shape   

  5.         android:shape="rectangle">  

  6.             <solid android:color="#FF0000" />  

  7.             <corners android:radius="30dp"/>  

  8.         </shape>  

  9.    </item>  

  10.   

  11.    <item android:left="30dp"  

  12.         >  

  13.       <shape   

  14.         android:shape="rectangle">  

  15.             <solid android:color="#FF0000" />  

  16.         </shape>  

  17.    </item>  

  18.   

  19. </layer-list>  

如今效果都同样了,android2.3.3效果以下:


相关文章
相关标签/搜索