0

我有这个问题,当我运行应用程序时,我的图像视图上方和下方会出现不需要的空白。

我曾尝试使用 adjustViewBounds 和不同的比例类型,问题是我想保持我的图片原样,但只需删除空格。

Imageviews 更改为我的 java 代码中的 src 图片,我将图片下载到手机活动,然后将图像设置为下载的位图。

这是它在我的模拟器上的外观图片,在您通过向下滚动 ScrollView 到达下一个 imageView 之前,会有一个全屏空白。

在此处输入图像描述

在这里你可以看到我的 XML 代码。TouchImageView 只是一种可缩放的 imageView。

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fadingEdge="none"
android:fillViewport="true" >

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

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

        <TextView
            android:id="@+id/tVInformation"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:text="TextView"
            android:visibility="gone" />

        <com.fluffow.csgosmokes.TouchImageView
            android:id="@+id/iVsmoke1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:adjustViewBounds="true"
            android:scaleType="centerInside"
            android:src="@drawable/ic_launcher" />

        <com.fluffow.csgosmokes.TouchImageView
            android:id="@+id/iVsmoke2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:adjustViewBounds="true"
            android:scaleType="centerInside"
            android:src="@drawable/ic_launcher" />

        <com.fluffow.csgosmokes.TouchImageView
            android:id="@+id/iVsmoke3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:adjustViewBounds="true"
            android:scaleType="centerInside"
            android:src="@drawable/ic_launcher" />

        <com.fluffow.csgosmokes.TouchImageView
            android:id="@+id/iVsmoke4"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:adjustViewBounds="true"
            android:scaleType="centerInside"
            android:src="@drawable/ic_launcher"
            android:visibility="invisible" />
    </LinearLayout>
</RelativeLayout>

An interesting thing is the fact that each imageview got exactly one android simulator screen "whitespace" between each other, and that if I color one imageviews-background half of the whitespace will be that color, the next half is from the next imageview. It got the same amount of whitespace before and after the imageview.

4

4 回答 4

1

问题出在touchImageView. 它创建了一个whitespace无法删除的。

于 2015-04-09T17:19:57.903 回答
0

You are using scale type centerInside and what it actually does is

Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or less than the corresponding dimension of the view (minus padding). The image is then centered in the view

Now your height is wrap_content so it will scale while maintaining the aspect ratio and once it hit either dimension it wont scale beyond that. If you want to remnove white space remove scaleType

于 2015-02-27T12:20:18.403 回答
0

Remove the android:scaleType="centerInside" from your TouchImageView and the white spaces between the consecutive TouchImageView should be removed.

于 2015-02-28T11:21:00.547 回答
0

尝试删除adjustViewBounds. 如果您的位图宽度小于屏幕宽度,这可能会在侧面产生空白,但否则效果很好。

于 2015-02-28T22:54:54.137 回答