0
点赞
收藏
分享

微信扫一扫

利用shape绘制渐变背景

J简文 2022-02-27 阅读 65
android5exml


  1. 线性渐变
    如从左到右,从上到下等

  • 效果图:
    利用shape绘制渐变背景_android
  • 代码:

<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绘制渐变背景_5e_02
  • 代码:

<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绘制渐变背景_5e_03
  • 代码:

<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背景渐变



举报

相关推荐

0 条评论