android java 图像显示不出来_java – Android ImageButton不显示图像,即使它在Designer预览中可见...

我正在尝试在

Android Studio中创建一个图像按钮. Designer预览正确显示图像,但是当我运行App时,Button中没有图像.只是一个尽可能小的空按钮.

我尝试过的事情:

>将Android drawable文件夹中的图像复制到我自己的drawable文件夹中

>根据stackoverflow上的一些消息来源,因为一个错误而创建占位符图像会阻止文件夹中的第一个图像不显示

>使用不同的图像

这些都不适合我.这就像整个功能刚刚被打破.有趣的是,当我设置我想要的图像作为图像按钮的背景时,它工作正常.但它失去了它的“按钮外观”,所以这对我来说不是解决方案.

xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:app="http://schemas.android.com/apk/res-auto"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical">

android:layout_width="match_parent"

android:layout_height="match_parent" />

android:id="@+id/search_ui"

xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_margin="5dp"

android:padding="1dp"

android:background="@color/white"

android:orientation="horizontal">

android:layout_width="wrap_content"

android:layout_height="wrap_content"

app:srcCompat="@drawable/ic_menu_manage"

android:id="@+id/imageButton"/>

android:layout_weight="1"

android:layout_width="0dp"

android:layout_height="wrap_content"

android:hint="@string/search_string" />

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="@string/button_send"

android:onClick="myClickHandler"/>

xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:padding="5dp"

android:background="@color/white"

android:layout_below="@id/search_ui">

android:id="@+id/display"

android:textSize="16sp"

android:textStyle="bold"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="New Text" />

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值