安卓图像按钮不显示



图像按钮未显示在我的应用程序中,但该按钮仍可单击其单击日志。

这是按钮:

<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 确实会显示可绘制图标和左侧工具栏,因此图像的路径是正确的。 首先,我想到了一个错误的z索引(我来自网络世界(。 但是据我所知,没有真正的 z 索引可以在 android 中给出标签。 什么可能进一步导致此问题

<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>

尝试使用 src 将图标设置为 ImageButton,例如

<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.

最新更新