gpt4 book ai didi

java - 将可见按钮移到不可见按钮上

转载 作者:行者123 更新时间:2023-12-02 00:13:35 25 4
gpt4 key购买 nike

好吧,我英语说得不好,所以很难解释我想要什么。

我在 Android 中有一个带有 2 个按钮的自定义对话框

<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp">

<Button android:id="@+id/button_ok"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginRight="5dp"
android:background="@drawable/dialog_button_background_selector"
style="@style/text_big_bold_inverted"
android:text="@string/ok"/>

<Button android:id="@+id/button_cancel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginRight="5dp"
android:background="@drawable/dialog_button_background_selector"
style="@style/text_big_bold_inverted"
android:text="@string/cancel"/>

</LinearLayout>

现在有时我只需要确定按钮,并且我使取消按钮不可见。但是 OK Button 一直在左边,是否可以在另一个不可见的情况下将 Button 移到中间?

我尝试使用.setGravity,但没有成功。

最佳答案

将“取消”按钮的可见性设置为 View.GONE 而不是 View.VISIBLE。

关于java - 将可见按钮移到不可见按钮上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12298367/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com