dialogfragment
そのため、単純な「ユーザーに選択してもらう」ポップアップを作成した後、それをロードすると、レイアウトに奇妙な余分な空白がいくつか見られました.何が原因なのかわからず、それを理解しようとして頭を悩ませていました. 動作をより適切に表示するために xml を少し変更しました。唯一の違いは、3 つの垂直セクションの幅を「match_parent」から「wrap_content」に変更したことです。これにより、ボーダーを使用して空白の実際のサイズを表示できます。 . 問題を示す図を次に示します。
ここに私のxmlがあります:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/pictureSourceMainTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/tvborder"
android:gravity="center"
android:text="Where would you like to choose\nyour image from?"
android:textAppearance="?android:attr/textAppearanceLarge" />
<LinearLayout
android:id="@+id/pictureSourceIVLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/tvborder"
android:weightSum="3" >
<ImageView
android:id="@+id/pictureSourceCancelIV"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_launcher" />
<ImageView
android:id="@+id/pictureSourceGalleryIV"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_launcher" />
<ImageView
android:id="@+id/pictureSourceCameraIV"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_launcher" />
</LinearLayout>
<LinearLayout
android:id="@+id/pictureSourceTVLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="3" >
<TextView
android:id="@+id/pictureSourceCancelTV"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/tvborder"
android:gravity="center"
android:text="Cancel" />
<TextView
android:id="@+id/pictureSourceGalleryTV"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:background="@drawable/tvborder"
android:gravity="center"
android:text="Gallery" />
<TextView
android:id="@+id/pictureSourceCameraTV"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:background="@drawable/tvborder"
android:gravity="center"
android:text="Camera" />
</LinearLayout>
</LinearLayout>
私の質問は次のとおりです。この余分な空白を削除するにはどうすればよいですか? 私のxmlレイアウトに何か欠けていますか? 幅のサイズは毎回手動で設定できますが、ウィンドウ自体を実際に「wrap_content」にしたいです。
編集:サイズ変更はタイトルが原因であることが判明しました。タイトルを適切なサイズに縮小する方法はありますか?