自定义背景

自定义背景

  1. 自定义一个背景颜色,让颜色从左到右变化的那种
    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>
  2. 自定义一个实心的小圆点

    <?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>

  • 邮箱 :charon.chui@gmail.com
  • Good Luck!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值