这是我的 Buttons.xml 文件
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="50dp"/>
<gradient android:startColor="#8E8816"
android:endColor="#145038"
android:angle="270" />
<stroke android:color="#680D0D" android:width="5dp"/>
</shape>
Run Code Online (Sandbox Code Playgroud)
这是我的 Activity_main.xml 我尝试将 android:background 更改为 android:src 但它也不起作用
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:background="@color/teal_700"
tools:context=".MainActivity">
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/buttons"
android:text="Button" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
只有角属性工作正常
不仅是中风,而且背景也没有改变,我没有明白我做错的地方......任何人都可以帮助我
这里将背景应用为 android:background="@drawable/buttons" Button_image后按钮的外观如何
android button android-button android-styles material-components-android