【问题标题】:How to create the custom drawable diagonal gradient如何创建自定义可绘制对角渐变
【发布时间】:2021-06-25 08:19:54
【问题描述】:

我想创建附图中显示的背景渐变。

目前我正在使用这个 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>

请帮帮我。

【问题讨论】:

标签: android xml android-layout android-drawable


【解决方案1】:

应该使用radial类型的gradient来使用这个你应该设置coordinates XY 作为centerXcenterYfinally 作为半径 使用这个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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-07-03
    • 1970-01-01
    • 2020-07-31
    • 1970-01-01
    • 1970-01-01
    • 2019-03-10
    • 1970-01-01
    • 2017-01-21
    相关资源
    最近更新 更多