Android 如何在imageview中以原始纵横比显示照片?

Android 如何在imageview中以原始纵横比显示照片?,android,layout,android-imageview,Android,Layout,Android Imageview,我想在ImageView中显示手机中的照片。这张照片应该以原始的纵横比显示。所以它应该填满整个宽度,但由于它的比例,只使用它所需要的高度。 简而言之:我希望在imageview中显示照片,而不进行缩放 我该怎么做?现在我正在使用这个布局。问题是它总是缩放照片以填满整个屏幕 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/a

我想在ImageView中显示手机中的照片。这张照片应该以原始的纵横比显示。所以它应该填满整个宽度,但由于它的比例,只使用它所需要的高度。 简而言之:我希望在imageview中显示照片,而不进行缩放

我该怎么做?现在我正在使用这个布局。问题是它总是缩放照片以填满整个屏幕

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/root" 
    android:orientation="vertical"
    android:background="@android:color/black">

<ImageView
    android:id="@+id/image"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:adjustViewBounds="true"
    android:scaleType="center" />

</LinearLayout>


尝试将图像放入
可绘制的nodpi
文件夹,并在ImageView中设置宽度和高度的
包裹父对象,并在
src
中设置指向图像的链接。为此,您可以在内部使用ScaleType CENTER。 有关更多详细信息,请访问链接。

尝试设置宽度以匹配父级,设置高度以包裹内容并调整视图边界:

    <ImageView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"
    android:src="@drawable/drawable"/>


wrap\u父级??这并不意味着
wrap_content
带有
centerInside
,如果图像小于
ImageView
它不会放大,它只会在视图中居中。如果它更大,它将缩小并居中。如果需要放大较小的图像,则必须使用
fitCenter
fitCenter
是ImageView的默认设置。
layout\u height=“wrap\u content”
难道不能解决这个问题吗?