Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/216.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 studio 4.2上的自定义按钮_Android_Xml_Button - Fatal编程技术网

android studio 4.2上的自定义按钮

android studio 4.2上的自定义按钮,android,xml,button,Android,Xml,Button,我是android studio新手,尝试自定义我的按钮,我在drawable文件夹中创建了一个新的xml文件,但是solid和padding属性不起作用 <?xml version="1.0" encoding="utf-8"?> <shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/an

我是android studio新手,尝试自定义我的按钮,我在drawable文件夹中创建了一个新的xml文件,但是solidpadding属性不起作用

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

    <solid android:color="#69EA64"/>
    <size android:height="100dp"
        android:width="150dp"/>
    <corners android:radius="50dp"/>
    <padding android:bottom="60dp"/>
    <stroke android:color="#FF0"
        android:width="5dp"
        android:dashGap="3dp"
        android:dashWidth="15dp"/>
    <gradient android:angle="45"
        android:startColor="#FF00"
        android:centerColor="#49A530"
        android:endColor="#FF0"/>
</shape>

这是我的XML代码:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <Button
        android:id="@+id/button"
        android:background="@drawable/custom_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="100dp"
        android:text="Button"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>


请帮助…

使工作
稳定
,删除
渐变

要进行
填充
请改用
插入
。要使用的完整代码:

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

    <shape
        android:shape="rectangle">

        <solid android:color="#69EA64" />
        <size
            android:width="150dp"
            android:height="100dp" />
        <corners android:radius="50dp" />
        <stroke
            android:width="5dp"
            android:color="#FF0"
            android:dashWidth="15dp"
            android:dashGap="3dp" />
    </shape>

</inset>

请同时发布您的XML代码。