【问题标题】:Load images in android without cropping from server?在android中加载图像而不从服务器裁剪?
【发布时间】:2012-11-19 20:25:41
【问题描述】:

我正在开发一个加载大量图像的应用程序。有像 facebook 这样的人的图像可能需要 30% 的屏幕尺寸和全宽。

Imageview 中的包装内容不显示完整的图像宽度。如果我在 imageview 中将比例类型设置为 fitxy,则图像会被拉伸,并且 centercrop 不能解决问题。我想从服务器获取图像而不进行裁剪,例如 facebooks 帖子。关于如何做到这一点的任何想法?

【问题讨论】:

  • 我很好:<ImageView android:id="@+id/one" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:adjustViewBounds="true" android:scaleType="centerCrop" />

标签: android android-imageview android-image


【解决方案1】:

如果您希望 ImageView 自动调整大小以保留图像的形状,您可以将 ImageView 的 android:adjustViewBounds 属性设置为 true。您还可以使用android:maxHeightandroid:maxWidth 指定最大宽度和高度。结合这三者,您可以在不裁剪和拉伸的情况下显示您的图像,并将其限制在适合您的 UI 的屏幕区域。

【讨论】:

  • Hmmm 不起作用 静止图像未缩放到设备全宽。以下是解决方案 stackoverflow.com/questions/4877694/… 但我有这么多位图,可能是因为比例因子我内存不足异常.
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-02-02
  • 2015-09-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多