安卓工作室中的梯度

2022-05-07

以下示例是关于Kotlin中包含安卓工作室中的梯度用法的示例代码,想了解安卓工作室中的梯度的具体用法?安卓工作室中的梯度怎么用?安卓工作室中的梯度使用的例子?那么可以参考以下相关源代码片段来学习它的具体使用方法。

[英]:gradient in android studio源码类型:Kotlin
In order to create a gradient, you create an xml file in res/drawable. I am calling mine my_gradient_drawable.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:type="linear"
        android:angle="0"
        android:startColor="#f6ee19"
        android:endColor="#115ede" />
</shape>
You set it to the background of some view. For example:

<View
    android:layout_width="200dp"
    android:layout_height="100dp"
    android:background="@drawable/my_gradient_drawable"/>

本文地址:https://www.itbaoku.cn/snippets/785329.html