Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何获得SimpleDraweView以正确显示图像?_Android_Android Studio_Fresco - Fatal编程技术网

Android 如何获得SimpleDraweView以正确显示图像?

Android 如何获得SimpleDraweView以正确显示图像?,android,android-studio,fresco,Android,Android Studio,Fresco,我有一个simpledraweview,它在一个回收器中 回收商: <android.support.v7.widget.RecyclerView android:id="@+id/recycler_view" android:layout_width="match_parent" android:layout_height="match_parent" /> SimpleDraweView: <com.facebook.drawee.view.S

我有一个
simpledraweview
,它在一个回收器中

回收商:

<android.support.v7.widget.RecyclerView
    android:id="@+id/recycler_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

SimpleDraweView:

<com.facebook.drawee.view.SimpleDraweeView
            android:id="@+id/feedImage"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:adjustViewBounds="true"
            />


我尝试了很多ratio和scaleType,但似乎无法获得显示完整高度的选项(仅显示90%)。宽度还可以,但我似乎不能正确地计算出高度。哪一种组合是获得适当相位的正确组合?(类似facebook)

我不太明白您要找的是哪种比例类型,但它肯定会由Fresco的lib配置为以下属性之一:

  fresco:actualImageScaleType="focusCrop|centerCrop|..."
  fresco:placeholderImageScaleType="fitCenter"
假设您有一些固定高度和100%宽度的图像视图:

  <com.facebook.drawee.view.SimpleDraweeView
        android:id="@+id/feedImage"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        fresco:actualImageScaleType="centerInside" />

我不太明白您要找的是哪种比例类型,但它肯定会由Fresco的lib配置,具有以下属性之一:

  fresco:actualImageScaleType="focusCrop|centerCrop|..."
  fresco:placeholderImageScaleType="fitCenter"
假设您有一些固定高度和100%宽度的图像视图:

  <com.facebook.drawee.view.SimpleDraweeView
        android:id="@+id/feedImage"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        fresco:actualImageScaleType="centerInside" />

我的假设是您有一个与父视图相关联的页边距。请完全链接您的XML文件,但很可能有一个带有边距集的RelativeLayout

另一件事,我在SimpleDraweView中看到android:layout\u height=“wrap\u content”。宽度将匹配父级,高度设置为包裹内容,因此如果没有此选项,它不会将高度扩展为100%。这就是为什么图像有90%的填充率。更改为:

<com.facebook.drawee.view.SimpleDraweeView
        android:id="@+id/feedImage"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:adjustViewBounds="true"
        />


除此之外,我还需要查看XML以确定是否有其他原因导致此问题

我的假设是,您有一个与父视图关联的边距。请完全链接您的XML文件,但很可能有一个带有边距集的RelativeLayout

另一件事,我在SimpleDraweView中看到android:layout\u height=“wrap\u content”。宽度将匹配父级,高度设置为包裹内容,因此如果没有此选项,它不会将高度扩展为100%。这就是为什么图像有90%的填充率。更改为:

<com.facebook.drawee.view.SimpleDraweeView
        android:id="@+id/feedImage"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:adjustViewBounds="true"
        />


除此之外,我还需要查看XML以确定是否有其他原因导致此问题

我只想看到整个画面。就像它在图库或网站上的显示方式。无论我使用哪一种,我只能看到图像高度的85%。我通常使用centerCrop,因此您将填充图像视图,但如果您希望它适合中心(所有部分都可见,没有任何部分被裁剪),则会有边距,既然imageView可能具有固定的高度和宽度,我如何才能获得facebook外观?我的意思是,如果我贴了一张照片,什么都不会被剪掉。它们的图像属性是什么?我现在知道了。谢谢,但这对于垂直图像来说太糟糕了。还有别的方法吗?我只是想看看整个画面。就像它在图库或网站上的显示方式。无论我使用哪一种,我只能看到图像高度的85%。我通常使用centerCrop,因此您将填充图像视图,但如果您希望它适合中心(所有部分都可见,没有任何部分被裁剪),则会有边距,既然imageView可能具有固定的高度和宽度,我如何才能获得facebook外观?我的意思是,如果我贴了一张照片,什么都不会被剪掉。它们的图像属性是什么?我现在知道了。谢谢,但这对于垂直图像来说太糟糕了。还有其他方法吗?我尝试对这两个参数使用match_parent,但由于某些原因,图像不会只显示一行。我在git上发布了相关信息,他们说因为我的图像在回收器中,所以它没有match_parent的tha参数。我尝试对这两个参数使用match_parent,但由于某些原因,图像不会只显示一行。我在git上发布了相关信息,他们说因为我的图片在一个回收站中,所以没有match_parent的tha参数。