Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/206.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
Java 安卓工作室-渐变背景&;(打、击等的)一下_Java_Android_Android Button_Material Components Android_Material Components - Fatal编程技术网

Java 安卓工作室-渐变背景&;(打、击等的)一下

Java 安卓工作室-渐变背景&;(打、击等的)一下,java,android,android-button,material-components-android,material-components,Java,Android,Android Button,Material Components Android,Material Components,我试图给我的按钮一个渐变背景和更强的笔触。我读过/看过很多教程,但都不适合我 这是我的addon.xml文件 <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:shape="rectangle"&

我试图给我的按钮一个渐变背景和更强的笔触。我读过/看过很多教程,但都不适合我

这是我的addon.xml文件

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

    <gradient android:startColor="#25AAFF"
        android:endColor="#004F81">
    </gradient>

    <stroke
        android:width="5dp"
        android:color="#000000">
    </stroke>

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

注意:角可以正常工作

和按钮文件

     <Button
        android:background="@drawable/login_button"
        android:id="@+id/login_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/login_password_input"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="20dp"
        android:text="@string/login_button_text"
        android:textColor="#FFFFFF"
        android:textStyle="bold">
    </Button>


使用材料组件库,
之间没有区别。查看更多信息

MaterialButton
被忽略
android:background
直到发布
1.2.0-alpha06
。 使用此版本,您可以使用类似以下内容的渐变背景:

<Button
    android:background="@drawable/bg_button_gradient"
    app:backgroundTint="@null"
    ... />
如果您使用的是早期版本的材质组件库,则可以使用
AppCompatButton

<androidx.appcompat.widget.AppCompatButton
    android:background="@drawable/bg_button_gradient"
    ..>

使用材料组件库,
之间没有区别。查看更多信息

MaterialButton
被忽略
android:background
直到发布
1.2.0-alpha06
。 使用此版本,您可以使用类似以下内容的渐变背景:

<Button
    android:background="@drawable/bg_button_gradient"
    app:backgroundTint="@null"
    ... />
如果您使用的是早期版本的材质组件库,则可以使用
AppCompatButton

<androidx.appcompat.widget.AppCompatButton
    android:background="@drawable/bg_button_gradient"
    ..>


您使用的是材料组件库吗?您使用的是材料组件库吗?