自定义背景
自定义一个背景颜色,让颜色从左到右变化的那种 在
res-drawable
目录下新建一个xml
文件。里面xml
文件内容的根节点是shape
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> //指定样式这里rectangle就是指定长方形 <corners android:radius="3dip"></corners> //指定边角的弧度 //颜色渐变,这里指定了开始、中间、结束三个颜色,样式就会从开始的比较淡变成中间的比较深, <gradient android:startColor="#33000000" android:centerColor="#bb000000" android:endColor="#33000000" ></gradient> <padding android:top="2dip" android:bottom="2dip" ></padding> <stroke android:width="4dip" //stroke用于指定边线 android:color="#ff0000" android:dashWidth="3dip" //dashWidth就是将边线变成了虚线的宽度 android:dashGap="2dip" //虚线的间距 </stroke> </shape>
自定义一个实心的小圆点
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" >//指定是椭圆,我们只要在使用的时候讲宽高设置为相等就是园了 <corners android:radius="5dip" /> <solid android:color="#88000000" /> //填充颜色 </shape>
- 邮箱 :[email protected]
- Good Luck!