在xml中禁用按钮点击效果

问题描述 投票:0回答:1

我在我的应用程序中创建了一个简单的ImageButton,并在其中使用和图像。

我有喜欢,当我点击按钮,它不会显示它被点击(不知道它是如何调用,但当按钮改变颜色)。

我的按钮看起来如下。

enter image description here

当我点击时,它变成了:

enter image description here

<ImageButton
    android:id="@+id/returnButton"
    style="?android:borderlessButtonStyle"
    android:layout_width="40dp"
    android:layout_height="0dp"
    android:layout_marginStart="16dp"
    android:src="@drawable/ic_rarrow"
    app:layout_constraintBottom_toBottomOf="@+id/tv_Username"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="@+id/tv_Username">
</ImageButton>

我想删除这个灰色的背景,即使在点击时,因为它显示的边界,我想隐藏。

谢谢你的建议

android xml android-imagebutton
1个回答
1
投票

你可以通过添加一行代码来解决这个问题。

android:background="@null"

希望它将被帮助


1
投票

您可以为 ImageButton

android:background="@android:color/transparent"

0
投票

应用一个背景到 Button:

android:background="@android:color/white"
© www.soinside.com 2019 - 2024. All rights reserved.