如何在运行时为不同屏幕调整图像大小? [英] How to resize images at runtime for different screens?

查看:81
本文介绍了如何在运行时为不同屏幕调整图像大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道Android Studio中有一些插件,其中包括可用于创建ldpi,mdpi,hdpi等图像资源的drawable.

I know that in Android Studio there are some plugins for including a drawable that help in creating a ldpi, mdpi, hdpi, etc image resource.

但是,假设我有一个应用程序,其中一些用户将图像上传到服务器,然后下载图像并显示给其他用户,我该如何调整它们以使其适应ldpi,mdpi和hdpi屏幕?服务器或客户端上是否有运行的库?

But suppose I have an app in which some users upload images to a server and then I download the images and display them for other users, how can I adapt them so that they adapt to ldpi, mdpi, hdpi screens? Is there a library that runs on the server or client?

推荐答案

有两种方法,您可以执行此操作,也可以让其他人执行

there are two ways , either you do it or let other do it

  1. 您可以使用带有拟合功能的picasso(图像加载库)并放松一下.

  1. you can use picasso(image loading library ) with fit function and just relax .link

找到所需的大小并使用所需的参数压缩图像大小.

find the required size and compress the image size with required parameter.android guide

还有其他一些库,例如picasso,glide,通用图像加载器和其他库,尽管picasso和glide在android开发人员中最受欢迎

there are couple of other library like picasso,glide,universal image loader and lot other though picasso and glide are most popular among android developers

代码参考链接:

> 毕加索

Picasso库以下载图像

使用毕加索

> 滑行

使用Glide从SD卡加载图像

libs的优点:

  • 内置图像下载机制,具有动画,调整大小等其他功能
  • 内置缓存机制
  • 由经验丰富的编码人员优化书面代码
  • 可以将图像从资源等加载到位图
  • 动画支持

缺点:

  • 与文档保持联系以获取新更新和更一致的功能

这篇关于如何在运行时为不同屏幕调整图像大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆