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 直线

相关推荐
生产队队长1 小时前
ThinkPHP:配置Redis并使用
android·数据库·redis
踏雪羽翼1 小时前
android 差值器的使用
android
Mr-Apple2 小时前
MySQL的Union和OR查询
android·数据库·mysql
yzpyzp2 小时前
如果后台的Long类型的数据返回是null,那么Android客户端的数据bean的kotlin的Long类型的字段接受到数据后是null空指针吗?
android·kotlin
hmywillstronger3 小时前
【Excel】【VBA】根据内容调整打印区域
android·excel
coooliang4 小时前
【Android】ViewPager的使用
android
xvch6 小时前
Kotlin 2.1.0 入门教程(二十五)类型擦除
android·kotlin
simplepeng14 小时前
我的天,我真是和androidx的字体加载杠上了
android
小猫猫猫◍˃ᵕ˂◍16 小时前
备忘录模式:快速恢复原始数据
android·java·备忘录模式
CYRUS_STUDIO18 小时前
使用 AndroidNativeEmu 调用 JNI 函数
android·逆向·汇编语言