android studio 4.2上的自定义按钮
我是android studio新手,尝试自定义我的按钮,我在drawable文件夹中创建了一个新的xml文件,但是solid和padding属性不起作用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
<?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代码。