如何防止禁用的Button在另一个ImageView或Button之后?

编辑:经过更多测试,我认为下面提到的问题是单击而不是禁用时发生的。研究海拔高度,看看点击是否可能改变这一点。

我正在使用约束布局,并且有两个包含图像的按钮。 用户单击时,其中之一将被临时或永久禁用。 问题?第二个按钮(应留在后面)最终覆盖另一个新禁用的按钮。 我尝试搜索与此有关的任何内容,但找不到任何可帮助我解决此问题的内容。我还尝试过将ImageView用作应该留在下方的按钮,但也无法正常工作。

// the button that should stay underneath 
<Button
        android:id="@+id/bg_pup_img"
        android:contentDescription="@string/pup2_desc"
        android:layout_width="0dp"
        android:layout_height="400dp"
        android:layout_marginTop="120dp"
        android:scaleType="fitEnd"
        android:background="@drawable/pup2"
        android:enabled="false"
        android:clickable="false"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/end_game"
        app:layout_constraintVertical_bias="1.5" />

// the button I want to stay at the top
<Button
        android:id="@+id/card19"
        android:layout_width="60dp"
        android:layout_height="80dp"
        android:layout_marginTop="30dp"
        android:layout_marginEnd="40dp"
        android:layout_marginRight="40dp"
        android:background="@drawable/blank_card"
        android:tag="19"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/card15" />

chendy0899 回答:如何防止禁用的Button在另一个ImageView或Button之后?

  

尝试将android:visibility =“”添加到“消失”或“不可见”

使您禁用按钮会将其置于后台。

,

如果我理解正确,您想在用户单击另一个按钮时显示一个按钮,如果是这种情况,为什么在用户单击后不使第二个按钮“不可见”

,

我似乎已经解决了我的问题。 我不完全确定单击时海拔的工作原理,但是当我单击“顶部”按钮时,它会位于“底部”按钮下方。 我将“底部”按钮的高度设置为0dp,而“顶部”按钮的高度设置为1dp。现在我不再有这个问题。

本文链接:https://www.f2er.com/3139725.html

大家都在问