【问题标题】:How to set gradiant color for stroke in shape in Android如何在Android中为形状中的笔划设置渐变颜色
【发布时间】:2017-03-11 13:35:38
【问题描述】:

我想创建自定义背景,我想在 drawable 文件夹中创建它。
对于这个背景,我写了下面的代码:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

    <stroke
        android:width="1dp"
        android:color="@color/gradient_center" />

    <corners android:radius="5dp" />

</shape>

但在这段代码中,我只是为stroke 设置sold 颜色,我想为stroke 颜色设置渐变 颜色。

怎么办?

【问题讨论】:

    标签: android android-drawable android-shape


    【解决方案1】:
    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android">
    
    <gradient
        android:angle="90"
        android:endColor="#b5b6d2"
        android:startColor="#555994"
        android:type="linear" />
    
    <corners android:radius="5dp" />
    
    </shape>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-01
      相关资源
      最近更新 更多