Android中控件布局背景设置渐变色

设置背景色就是直接设置控件的android:background为自定义效果的xml文件

上下渐变的效果图:
Android中控件布局背景设置渐变色
xml代码:

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

左右渐变的效果图:
Android中控件布局背景设置渐变色
xml代码:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:startColor="#1215dc"
        android:endColor="#8ab4f2"
        android:angle="180"
        />
</shape>

倾斜渐变的效果图:
Android中控件布局背景设置渐变色
xml代码:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:startColor="#1215dc"
        android:centerColor="#70a6f5"
        android:endColor="#1215dc"
        android:angle="135"
        />
</shape>

其中
startColor:头部颜色
endColor:尾部颜色
centerColor:中部颜色
angle:倾斜角度

相关文章:

  • 2022-12-23
  • 2021-08-23
  • 2022-12-23
  • 2021-09-26
  • 2022-12-23
  • 2021-12-23
  • 2022-12-23
  • 2021-09-11
猜你喜欢
  • 2021-11-05
  • 2021-06-25
  • 2022-12-23
  • 2021-06-26
  • 2021-09-26
  • 2021-09-16
  • 2021-11-18
相关资源
相似解决方案