Android使用shape定义带渐变色的背景

在drawable目录下创建文件bg_gradient.xml

文件内的内容如下:

<?xml version="1.0" encoding="utf-8"?>

<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">

<gradient android:type="linear" android:useLevel="true" android:startColor="#ff028f43" android:endColor="#ff6abf23" android:angle="90" />

<corners android:topLeftRadius="0dp" android:topRightRadius="0dp" android:bottomLeftRadius="36dp" android:bottomRightRadius="36dp" />

</shape>

angle表示渐变角度

渐变角度,仅用于线性渐变。必须是[0-315]范围内45的倍数。

angle: 0 从左到右

angle 90 从下往上

angle 180 从右往左

angle 270 从上往下

type : linear 直线

相关推荐
Jomurphys2 小时前
Compose 调用 - 震动 LocalHapticFeedback
android·compose
非凡ghost2 小时前
小X分身APP(手机分身类工具)
android·windows·学习·智能手机·软件需求
erqi5 小时前
Compose你入门吧
android
q***76565 小时前
MySQL 中如何进行 SQL 调优
android·sql·mysql
zhanglinping6195 小时前
MySQL——内置函数
android·数据库·mysql
m***78745 小时前
mysql之字符串函数
android·数据库·mysql
w***71106 小时前
MySQL 事务的操作和四大特性
android·数据库·mysql
松叶似针8 小时前
Flutter三方库适配OpenHarmony【secure_application】— Android 端 FLAG_SECURE 实现分析
android·flutter
cjl_8520089 小时前
[MySQL] MySQL复合查询(多表查询、子查询)
android·mysql·adb
stevenzqzq10 小时前
Barrier的用法
android