我有一个很小但很奇怪的问题,我似乎无法解决。 我正在尝试为我的按钮显示一个图像,它显示为一个黑色方 block 。 我之前制作的按钮显示出来并且工作正常,但是这个按钮(以及我之后制作的其他按钮)显示为黑色方 block .. 现在,如果我将其更改为 ImageView 而不是 Button,它会正常显示。
有没有人遇到过这个问题?如果是这样,你是如何解决的? 我仍然是编程的新手,我正在自学,所以我真的没有任何帮助,我已经尝试修复它一段时间了。 :(
这是按钮/图像的 xml。
<RelativeLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:id="@+id/pause"
android:src="@drawable/pause"
android:layout_width="29px"
android:layout_height="29px"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="15dp"
android:layout_marginRight="10dp">
</Button>
</RelativeLayout>
如果您有任何其他问题,请提出,非常感谢您查看我的问题! :)
最佳答案
使用 ImageButton
代替 Button
或将 android:src="@drawable/pause"
更改为 android:background ="@drawable/pause"
关于安卓按钮 : Displaying black square and not img?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9199431/