Reputation: 563
The image button does not show up in my app, but the button is still clickable its click log works.
This is the button:
<ImageButton
android:id="@+id/stopStream"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_margin="10dp"
android:background="@drawable/cancel_btn"
android:contentDescription="@string/stop_stream"
android:onClick="hangup"
android:visibility="visible" />
Android Studio does show the drawable icon and the left toolbar, so the path of the image is correct. First I thought of having a wrong z-index (I come from the web world). But there is not a real z-index to give a tag in android as far as I read. What could further cause this issue
<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"
android:background="@android:color/black"
tools:context="de.app.test.VideoChatActivity">
<android.opengl.GLSurfaceView
android:id="@+id/gl_surface"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
<ImageButton
android:id="@+id/stopStream"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_margin="10dp"
android:background="@drawable/cancel_btn"
android:contentDescription="@string/stop_stream"
android:onClick="hangup"
android:visibility="visible" />
<ImageButton
android:id="@+id/switchCameraBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignTop="@+id/stopStream"
android:layout_marginEnd="9dp"
android:background="@color/transparent"
android:contentDescription="@string/send"
android:visibility="gone" />
<ImageButton
android:id="@+id/switchBtn"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentEnd="true"
android:layout_alignTop="@+id/switchCameraBtn"
android:layout_marginEnd="9dp"
android:background="@drawable/call_btn"
android:contentDescription="@string/send" />
<RelativeLayout
android:id="@+id/drawable_mod"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:gravity="center"
android:orientation="horizontal"
android:visibility="gone">
<ImageView
android:id="@+id/drawing1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:scaleType="fitXY"
android:contentDescription="@string/drawing_one" />
</RelativeLayout>
</RelativeLayout>
Upvotes: 0
Views: 75
Reputation: 1522
Try using src to set your icon to ImageButton, like
<ImageButton
android:id="@+id/stopStream"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_margin="10dp"
android:src="@drawable/cancel_btn"
android:background="@null"
android:contentDescription="@string/stop_stream"
android:onClick="hangup"
android:visibility="visible" />
//used background="@null" to set the image button background as null to only show the icon which was set with the src.
Upvotes: 1