<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <gradient android:startColor="#dddddd" android:endColor="#ff7f27" /> <stroke android:width="1dp" android:color="#aaaaaa" /> <corners android:radius="25dp" /> <padding android:left="30dp" android:right="30dp" android:top="10dp" android:bottom="10dp" /> </shape>
文件名:myBG.xml,位置:res/drawable/
gradient:渐变;stroke: 描边;conrners:圆角;padding:内边距;
上面代码的效果:
----------------------------
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <gradient android:startColor="#dddddd" android:centerColor="#555555" android:endColor="#ff7f27" android:angle="270" /> <stroke android:width="1dp" android:color="#aaaaaa" /> <corners android:radius="15dp" /> </shape>
代码效果:
----------------------------------
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <gradient android:startColor="#dddddd" android:endColor="#ff7f27" android:type="radial" android:gradientRadius="100" android:centerX="0.5" android:centerY="0.2" /> <stroke android:width="1dp" android:color="#aaaaaa" /> <corners android:radius="15dp" /> </shape>
gradientRadius:渐变半径 ;
代码效果:
扫描二维码关注公众号,回复:
849661 查看本文章
![](/qrcode.jpg)
---------------------------
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <gradient android:startColor="#dddddd" android:endColor="#ff7f27" android:type="sweep" android:gradientRadius="100" android:centerX="0.5" android:centerY="0.5" /> <stroke android:width="1dp" android:color="#aaaaaa" /> <corners android:radius="15dp" /> </shape>
代码效果:
没做详细讲解,这仅仅是我备忘用。。。。