我正在尝试在
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" />