0

ダイアログとして使用される次のレイアウトで使用すると、相対的なレイアウトビューを縮小できません。以下の例では、スクロールビューは常に展開されてダイアログ全体に表示されますが、実際のコンテンツがあまりない場合は非常に見苦しく見えます。

fill_parent、wrap_contentなどのほとんどの組み合わせを試しましたが成功しませんでした。

問題は、ボタンを「align_bottom」に設定すると、ダイアログがその高さいっぱいになることだと思われます。しかし、順序を変更してスクロールビューの下にボタンを配置する必要がある場合、多くのコンテンツが表示されているとボタンは表示されません...

回避策(非常に醜い解決策だと思います)は、スクロールビューにマージン下部を設定してから、ボタンに同じ負のマージン上部を設定することです。しかし、これがさまざまなディスプレイでどのように見えるかはわかりません。

/Rudasを助けてください

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

    <ScrollView
        android:id="@+id/ScrollView01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/dialogCloseButton"
        android:layout_alignParentTop="true" >

        <LinearLayout
            android:id="@+id/dialogContent"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:paddingBottom="10dp" >

            <TextView
                android:id="@+id/TextView01"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >
            </TextView>
        </LinearLayout>
    </ScrollView>

    <Button
        android:id="@+id/dialogCloseButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:text="Close" >
    </Button>

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

    <ScrollView
        android:id="@+id/ScrollView01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/dialogCloseButton"
        android:layout_alignParentTop="true" >

        <LinearLayout
            android:id="@+id/dialogContent"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:paddingBottom="10dp" >

            <TextView
                android:id="@+id/TextView01"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >
            </TextView>
        </LinearLayout>
    </ScrollView>

    <Button
        android:id="@+id/dialogCloseButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:text="Close" >
    </Button>

</RelativeLayout>
4

1 に答える 1

0

ScrollView は FrameLayout の特殊なタイプです。これは、常に親レイアウトの左上隅から開始されることを意味します。効果が他のビューに重なっており、RelativeLayout 設定は効果がありません。解決策は、StrollView を別のレイアウト (たとえば、LinearLayout) に配置することです。

于 2010-08-03T08:49:55.193 に答える