i am trying to create an Image Button in Android Studio. The Designer preview shows the image correctly, but when I run the App there is no image in the Button. Just an empty button as small as possible.
Things I have tried:
- Copying the image from the Android drawable folder into my own drawable folder
- Creating a placeholder image because of a bug the prevents the first image in the folder to not show up, according to some sources on stackoverflow
- Using different images
None of this worked for me. It is like the whole function is just broken. The interesting part is, when I set the image I want as the background of the imagebutton it works fine. But it looses its "button-appearence", so thats not a solution for me.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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">
<org.osmdroid.views.MapView android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout
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">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_menu_manage"
android:id="@+id/imageButton"/>
<EditText android:id="@+id/edit_search_string"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/search_string" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send"
android:onClick="myClickHandler"/>
</LinearLayout>
<LinearLayout
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">
<TextView
android:id="@+id/display"
android:textSize="16sp"
android:textStyle="bold"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="New Text" />
</LinearLayout>