2

カスタム ダイアログがありますが、dialog.xml から膨らませています。ダイアログを開くと、次のようになります。リストビューとその下の (OK) ボタンの間にスペースができています。リスト ビューとその下のボタンの間のこのスペースを削除したいと考えています。これどうやってするの、?

ここに画像の説明を入力

dialog.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RelativeLayout1"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent" >

    <ListView
        android:id="@+id/listViewDialog"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_above="@+id/button1"
        android:layout_below="@+id/ImageView1" >
    </ListView>

    <CheckBox
        android:id="@+id/checkBoxAll"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/listView1"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="15dp"
        android:layout_marginRight="25dp"
        android:layout_marginTop="15dp"
        android:text="" />

    <ImageView
        android:id="@+id/ImageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginBottom="15dp"
        android:layout_marginLeft="14dp"
        android:layout_marginTop="15dp"
        android:background="#FFFFBB33"
        android:contentDescription="@string/app_name"
        android:scaleType="center"
        android:src="@drawable/alert_dialog_icon" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="128dp"
        android:layout_height="match_parent"
        android:layout_above="@+id/listViewDialog"
        android:layout_marginBottom="15dp"
        android:layout_marginTop="15dp"
        android:layout_toRightOf="@+id/ImageView1"
        android:gravity="center_vertical"
        android:text="Categories"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/textView1"
        android:layout_alignBottom="@+id/textView1"
        android:layout_toLeftOf="@+id/checkBoxAll"
        android:text="All"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <Button
        android:id="@+id/button1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:text="OK" />

</RelativeLayout>
4

2 に答える 2

2

これは本当に簡単です.. 2 つのアプローチがあります。これにより、すべてのダイアログのサイズが右側 (スペースなし) に縮小されます。2) *もっとお勧めします。ルートを Linearlayout にして、いくつかの wightsum を与えてから、他のビューをこのルートに置き、それらにいくつかの layout_wight を与えます。このようにして、どの画面解像度でも同じ割合を持っていることがわかります。画面。

于 2012-12-17T08:45:58.740 に答える
0
maybe try like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RelativeLayout1"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:weightSum="100" >

        <LinearLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/RelativeLayout1"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_weight="15" >

            <CheckBox
                android:id="@+id/checkBoxAll"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_above="@+id/listView1"
                android:layout_alignParentRight="true"
                android:layout_marginBottom="15dp"
                android:layout_marginRight="25dp"
                android:layout_marginTop="15dp" />

            <ImageView
                android:id="@+id/ImageView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentTop="true"
                android:layout_marginBottom="15dp"
                android:layout_marginLeft="14dp"
                android:layout_marginTop="15dp"
                android:background="#FFFFBB33"
                android:contentDescription="@string/app_name"
                android:scaleType="center" />

            <TextView
                android:id="@+id/textView1"
                android:layout_width="128dp"
                android:layout_height="match_parent"
                android:layout_above="@+id/listViewDialog"
                android:layout_marginBottom="15dp"
                android:layout_marginTop="15dp"
                android:layout_toRightOf="@+id/ImageView1"
                android:gravity="center_vertical"
                android:text="Categories"
                android:textAppearance="?android:attr/textAppearanceLarge" />

            <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBaseline="@+id/textView1"
                android:layout_alignBottom="@+id/textView1"
                android:layout_toLeftOf="@+id/checkBoxAll"
                android:text="All"
                android:textAppearance="?android:attr/textAppearanceLarge" />
        </LinearLayout>

        <ListView
            android:id="@+id/listViewDialog"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="70" >
        </ListView>

        <LinearLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_weight="15" >

            <Button
                android:id="@+id/button1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:text="OK" />
        </LinearLayout>
    </LinearLayout>

</LinearLayout>
于 2012-12-17T11:35:24.217 に答える