Android开发经验谈安卓开发安卓开发

利用shape绘制渐变背景

2019-07-31  本文已影响5人  蓝不蓝编程
  1. 线性渐变
    如从左到右,从上到下等
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
            android:startColor="#2193b0"
            android:endColor="#6dd5ed"
            android:angle="90"/>
    <corners android:radius="4dp"/>
</shape>
  1. 放射性渐变
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
            android:startColor="#2193b0"
            android:endColor="#6dd5ed"
            android:gradientRadius="150"
            android:type="radial"
            android:angle="90"/>
    <corners android:radius="4dp"/>
</shape>
  1. 扫描式渐变
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
            android:startColor="#2193b0"
            android:endColor="#6dd5ed"
            android:type="sweep"
            android:angle="90"/>
    <corners android:radius="4dp"/>
</shape>

Demo源代码

https://github.com/cxyzy1/gradientShapeDemo

附录

关于Android shape gradient背景渐变

上一篇 下一篇

猜你喜欢

热点阅读