1

私はこれを理解しようと多くの時間を費やしました。ダイアログ レイアウトを作成し、タイトルの両側に 2 つのボタンを配置しながら、タイトルをダイアログに対して中央に配置しようとしています。ボタンは、左端と右端に向かって「重力調整」されます。

簡単な部分は、ダイアログを中央に配置するか、左端と右端のボタンを実行することです。それは彼らが同じラインでお互いに仲良くすることです.

それについて考える簡単な方法:

  1. タイトルはダイアログの中央に配置されます
  2. 2 ボタンは同一線上で左右に独立して配置されます

これを行う方法について何か考えはありますか?

4

1 に答える 1

0

IMOカスタマイズされたダイアログを実行し、TableLayoutを使用して要素を配置しようとします。このようにして、ボタンを配置し、タイトルの属性stretchcolumnを使用して、画面の横にあるボタンを押すことができます。(私があなたをよく理解している場合)
代替テキストhttp://img801.imageshack.us/img801/4372/tablelayout.png
このxmlの例を使用すると、機能し、画面サイズ/回転から独立しているはずです。

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:stretchColumns="1">

<TableRow android:id="@+id/TableRow01" android:layout_width="wrap_content"
    android:layout_height="wrap_content">
    <Button android:text="Button01" android:id="@+id/Button01"
        android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
    <TextView android:text="This is your title" android:id="@+id/TextView01"
        android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_horizontal" ></TextView>
    <Button android:text="Button02" android:id="@+id/Button02"
        android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
</TableRow>
</TableLayout>
于 2010-07-22T21:38:33.087 に答える