android - 如何创建自定义可绘制对角渐变
问题描述
我想创建附加图像中显示的背景渐变。
目前我正在使用这个 xml,它没有提供所需的效果:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="225"
android:endColor="#FF5C1E"
android:startColor="#A300F3"
android:type="linear"
android:useLevel="false" />
</shape>
解决方案
您应该使用radial
类型gradient
来使用它,您应该将coordinates
X和Y设置为centerX
,centerY
最后 对于半径使用此字段。gradientRadius
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:centerX="0.9"
android:centerY="0.1"
android:endColor="#FF5C1E"
android:gradientRadius="1700"
android:startColor="#A300F3"
android:type="radial" />
</shape>
推荐阅读
- nvidia - 强制 DirectX 11 VSync,即使在 Nvidia 控制面板中关闭
- python - Linux 上的 Rpy2。“R 库不包含包”-错误
- python-3.x - 如何使用 Ajax 方法获取网站数据
- node.js - 用于从应用程序帐户到卖方的服务器付款的 PayPal api
- spring - 无法在 Maven 项目中安装 spring 上下文依赖项
- jquery - 更改活动导航项的颜色并显示相对于导航栏项的页面
- xml - 如何在 Oracle 中解决此内存错误
- javascript - Styling rendered iframe in react
- javascript - 对于参数(x,y)的循环错误继续绘制html画布
- python-3.x - 用目录中文件路径的循环列表替换文件中的行字符串