4

ImageView を含む ScrollView を使用しようとしています。それのための私のxmlコードはこれです:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:fillViewport="true"
    android:layout_gravity="right" >

        <ImageView
            android:id="@+id/tapjoy_dialog_image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="10dp"
            android:src="@drawable/untitled" />

</ScrollView>

奇妙なことに、実行すると、画像の上下に非常に広いパディングが表示されます。私の言いたいことを理解するために、私が添付したスクリーンショットを見てください。

ScrollView スナップショット

どうすればこれを解決できますか?

もっと奇妙なことに:

  1. ScrollView を削除して ImageView のみを残すと、パディングされず、うまく機能します。

  2. ImageView を削除し、代わりに大きな textView を配置すると、パディングもうまく機能しません。

したがって、問題はScrollViewとImageViewの組み合わせに多少関連していると思います...

ImageView に入れようとしている画像は次のとおりです。 ここに画像の説明を入力

4

2 に答える 2

7

に追加android:adjustViewBounds="true"しますImageView

于 2012-02-08T02:48:34.147 に答える
0

//スクロール ビューの親レイアウトを 1 つ追加します

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:fillViewport="false"
    android:layout_gravity="right" >
<LinearLayout  android:layout_width="fill_parent"
            android:layout_height="fill_parent" >
        <ImageView
            android:id="@+id/tapjoy_dialog_image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="10dp"
            android:src="@drawable/untitled" />

</LinearLayout>
</ScrollView>
于 2012-02-07T14:01:56.030 に答える