好吧,我不会说一口流利的英语,所以很难解释我想要什么。
我在 Android 中有一个自定义对话框,带有 2Buttons
<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>
现在有时我只需要 OKButton并且我使取消Button不可见。但是 OKButton停留在左边,Button当另一个不可见时,是否可以将其移动到中心?
我尝试使用.setGravity,但没有奏效。