Android can';t更改按钮的背景图像

Android can';t更改按钮的背景图像,android,android-studio,android-layout,Android,Android Studio,Android Layout,我在photoshop中创建了一个按钮图像,但当我在应用程序上使用它时,它只是崩溃了。我想我需要一个指定的尺寸。该应用程序工作正常,没有按钮的背景图像 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" a

我在photoshop中创建了一个按钮图像,但当我在应用程序上使用它时,它只是崩溃了。我想我需要一个指定的尺寸。该应用程序工作正常,没有按钮的背景图像

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Test" />

</RelativeLayout>


您是否尝试过使用
ImageButton
而不是
按钮



你的崩溃日志是什么?图像按钮不接收文本如果需要文本,并且你已经在普通按钮上尝试了android:background=“@drawable/button\u bg”,那么我可以查看你的崩溃日志吗?我无法添加崩溃日志,他们说“看起来你的帖子主要是代码;请添加更多细节。“你能抓起它的图像并将其发布到原始问题中吗?”?可能可以在那里看到一些东西崩溃日志中最有趣的部分是由以下原因引起的:android.content.res.Resources$NotFoundException:资源不是可绘制的(颜色或路径):TypedValue{t=0x1/d=0x7f030002 a=-1 r=0x7f030002}
<ImageButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="sourceDrawableHere"/>