0

わかりました、私は上手な英語を話せないので、私が何を望んでいるかを説明するのは難しいでしょう.

Androidに2のカスタムダイアログがありますButtons

<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非表示にします。OKButtonは左のままですがButton、もう一方が見えない状態で中央に移動することはできますか?

使ってみ.setGravityましたがダメでした。

4

2 に答える 2

2

[キャンセル] ボタンの可視性を View.VISIBLE ではなく View.GONE に設定します。

于 2012-09-06T10:50:48.103 に答える
1

android:layout_gravity="center_horizontal"最初に LinearLayout に設定します。

次に、View.INVISIBLE の代わりに View.GONE を Button に使用します。

button.setVisibility(View.GONE);
于 2012-09-06T10:50:39.893 に答える