如何将图像大小调整为原始大小

时间:2013-12-29 16:54:45

标签: android imageview

Android的imageView有一个严重的缺陷:它将我的图像变成方框,其余为白色空间。我怎样才能解决这个问题?我尝试过尺度类型,但它没有用。谢谢。 This is the original image

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:contentDescription="@string/header"
        android:scaleType="fitStart"
        android:src="@drawable/img_001" />

</RelativeLayout>

The problem

1 个答案:

答案 0 :(得分:1)

没有您的代码,我只能猜测,但我建议您添加xml属性android:adjustViewBounds="true"或在您的活动中,为imageview提供imageView.setAdjustViewBounds(true)

的属性