0

次の XML を見てください。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#ffffff" >

    <TextView
        android:id="@+id/save_txt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="22dp"
        android:text="@string/save_to" />

    <LinearLayout
        android:id="@+id/save_location_radio_layout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical" 
        android:layout_toRightOf="@+id/save_txt"
        android:layout_marginTop="22dp"
        android:layout_marginLeft="5dp"
        android:layout_alignBaseline="@+id/save_txt">

        <RadioGroup
        android:id="@+id/save_selection_group"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">


    <RadioButton
        android:id="@+id/radio_sd"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:checked="true"
        android:text="SD" />

    <RadioButton
        android:id="@+id/radio_phone"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Phone" />
    </RadioGroup>
    </LinearLayout>





    <TextView
        android:id="@+id/save_name_txt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/save_txt"
        android:layout_marginTop="50dp"
        android:text="@string/save_name" />

    <EditText
        android:id="@+id/save_name_edt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/save_txt"
        android:layout_toRightOf="@+id/save_name_txt"
        android:layout_alignBaseline="@+id/save_name_txt"
        android:layout_marginLeft="15dp"
        android:paddingBottom="10dp"
        android:ems="8" >

        <requestFocus />
    </EditText>

    <Button
        android:id="@+id/save_voice_note_button"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/save_txt"
        android:layout_toRightOf="@+id/save_name_edt"
        android:layout_alignBaseline="@+id/save_name_edt"
        android:layout_marginLeft="5dp"
        android:paddingBottom="10dp"
        android:text="@string/save" />

</RelativeLayout>

これにより、次のものが生成されます

ここに画像の説明を入力

2つの問題があります。

  1. ご覧のとおり、RadioButtons は「保存先:」の右側に配置されていません。TextView
  2. これは実際には、Dialogこのウィンドウを開くと、ウィンドウの高さが十分ではありません。EditText画像を参照してください。との 90% しか表示されていませんButton

これを修正するために最善を尽くしましたが、それでもうまくいきません。私は何を間違えましたか?

4

4 に答える 4

1

ダイアログの高さの問題を修正するandroid:layout_heightには、メインの RelativeLayout を に変更しますwrap_content

ラジオ ボタンを TextView に揃えるには、 と を次のように変更@+id/save_txt@+id/save_location_radio_layoutます。

<TextView
    android:id="@+id/save_txt"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/save_to" 
    android:gravity="center_vertical"
    android:layout_alignTop="@+id/save_location_radio_layout"
    android:layout_alignBottom="@+id/save_location_radio_layout"/>

<LinearLayout
    android:id="@+id/save_location_radio_layout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical" 
    android:layout_toRightOf="@+id/save_txt"
    android:layout_marginTop="22dp"
    android:layout_marginLeft="5dp">
于 2013-11-14T13:00:43.243 に答える
0

保存先: テキストビューも最初の線形レイアウトに配置し、テキストビューとラジオグループの間にパディングを与えます..

于 2013-11-14T12:38:14.450 に答える
0

上記のコメントに加えて。

ダイアログのサイズは画面のサイズに依存するため、すべての要素がダイアログに収まるとは限りません。画面の大部分にうまく収まるように UI を最適化し、ScrollView を RelativeLayout にラップする必要があります。新しいルート要素になります。

于 2013-11-14T12:44:00.227 に答える