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>

奇怪的是,当我运行它时,图像的顶部和底部都有一个非常宽的填充。要理解我的意思,请查看我附上的屏幕截图。

滚动视图快照

我该如何解决这个问题?

更奇怪的是:

  1. 当我删除 ScrollView 并仅保留 ImageView 时,它不能很好地工作。

  2. 当我删除 ImageView 并放置一个大的 textView 时,它也不能很好地工作。

所以,我认为这个问题有点与 ScrollView 和 ImageView 的组合有关......

我尝试放入 ImageView 的图像是这样的: 在此处输入图像描述

4

2 回答 2

7

添加android:adjustViewBounds="true"到您的ImageView.

于 2012-02-08T02:48:34.147 回答
0

//为滚动视图添加一个父布局

<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 回答