Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/188.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何将gradient drawable设置为FloatingActionButton上的backgroundTint属性_Android_Drawable_Gradient_Background Color_Floating Action Button - Fatal编程技术网

Android 如何将gradient drawable设置为FloatingActionButton上的backgroundTint属性

Android 如何将gradient drawable设置为FloatingActionButton上的backgroundTint属性,android,drawable,gradient,background-color,floating-action-button,Android,Drawable,Gradient,Background Color,Floating Action Button,我想使用渐变色而不是传统的纯色作为浮动动作按钮 我已经知道如何使用ColorStateList修改按钮的背景色。有没有办法实现以下可绘制的背景色调 overlay.xml <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startColor="#c25f82"

我想使用渐变色而不是传统的纯色作为浮动动作按钮

我已经知道如何使用
ColorStateList
修改按钮的背景色。有没有办法实现以下可绘制的背景色调

overlay.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">

    <gradient
        android:startColor="#c25f82"
        android:endColor="#5a3e60"
        android:angle="-270" />

</shape>


不。正如您已经注意到的,色调始终是纯色。您可以将任何内容设置为背景,但我想这种方法将打破支持范围。

不。正如您已经注意到的,色调始终是纯色。你可以将任何东西设置为背景,但我想这种方法会破坏支持晶圆厂。

是的,你可以将渐变设置为晶圆厂,我刚刚发现了一个问题

1.)在drawable文件夹中创建一个gradient.xml,并在其中添加以下代码

    <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <gradient
        android:type="linear"
        android:angle="0"
        android:startColor="#03a9f4"
        android:endColor="#e91e63" />
</shape>

2.)在dimens.xml中添加这一行

<dimen name="design_fab_image_size" tools:override="true">56dp</dimen>
56dp

3.)在你的晶圆厂中添加
android:src=“@drawable/gradient”
是的,你可以设置晶圆厂的渐变,我刚刚发现了一个问题

1.)在drawable文件夹中创建一个gradient.xml,并在其中添加以下代码

    <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <gradient
        android:type="linear"
        android:angle="0"
        android:startColor="#03a9f4"
        android:endColor="#e91e63" />
</shape>

2.)在dimens.xml中添加这一行

<dimen name="design_fab_image_size" tools:override="true">56dp</dimen>
56dp
3.)在您的晶圆厂中添加
android:src=“@drawable/gradient”