0

I'm trying to create a CRUD android application. Now, when the List Activity is shown, it will display the items created along with a thumbnail of the original image.

What is the best practice for displaying a thumbnail in an Android application with Volley? Should I generate a thumbnail for the images uploaded or just re-size the image at the client side?

4

1 回答 1

0

很难为这个问题想出一个通用的答案,因为这完全取决于您尝试下载的图像数量以及显示缩略图的重要性。

一旦用户上传缩略图,我会亲自在服务器端生成缩略图。这样做有几个好处:

  1. 您的应用程序所要做的就是请求缩略图并渲染它,这比使用 Volley 的ImageRequest.

  2. 较小的图像意味着更少的数据使用。您绝对不希望您的应用程序通过 3G 连接下载 10MB 25 兆像素的图像,只是为了将其缩小为用户可能根本不关心的 100x100 缩略图。

我能想到的唯一缺点是您可能必须生成多个缩略图,每个屏幕尺寸一个(例如一个用于 hdpi 屏幕,另一个用于 xxhdpi)。这在服务器端稍微贵一些,但可能会使您的 UI 看起来更好。

此外,请记住将缩略图缓存在应用程序的缓存目录中,这样您就不必每次想要显示它们时都重新请求它们。

于 2015-02-05T19:33:41.277 回答