我在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>
答案 0 :(得分:1)
您是否尝试过使用ImageButton
而不是Button
?
https://developer.android.com/reference/android/widget/ImageButton
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="sourceDrawableHere"/>