侧边栏壁纸
博主头像
Stars-One的杂货小窝博主等级

所有的创作都是有价值的

  • 累计撰写 257 篇文章
  • 累计创建 46 个标签
  • 累计收到 27 条评论

目 录CONTENT

文章目录

Android xml背景属性记录

Stars-one
2024-03-14 / 0 评论 / 0 点赞 / 6 阅读 / 2595 字

shape

corners 圆角

属性
radius设置所有 bottomRightRadius 右下角圆角

stroke 边框

color 边框颜色
width 边框宽度

solid 填充背景

color 背景颜色

gradient 渐变

startColor 开始颜色
endColor 结束颜色
angle 角度 0 90 180 270 可以设置渐变的方向

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <corners
        android:bottomRightRadius="5dp" android:topRightRadius="5dp">
    </corners>
    <stroke android:width="1px" android:color="#bbd8ea"/>
    <solid
        android:color="#e7f2f8">
    </solid>
    <!-- <gradient android:startColor="" android:endColor="" android:angle="90"/> -->
</shape>

PS:注意solid和gradient的顺序,两者联用,位于xml下面的会覆盖上面的,如

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <solid
        android:color="#e7f2f8">
    </solid>
    <gradient android:startColor="" android:endColor="" android:angle="90"/>
</shape>

gradient会覆盖solid

透明色 前面的两位

<solid
        android:color="#4DFFFFF2">
    </solid>
0

评论区