简体   繁体   English

如何根据屏幕分辨率调整图像大小?

[英]How can I resize the image according to screen resolution?

在此处输入图片说明

I am using an image in my application and I want it to fit correctly on all the device even they have different resolution. 我在应用程序中使用图像,并且即使它们具有不同的分辨率,我也希望图像能够正确地适合所有设备。 Is there any way we can resize the image according to screen size? 有什么方法可以根据屏幕尺寸调整图像大小?

Yes you can, there are two alternative ways to do it; 是的,您可以这样做,有两种替代方法;

  1. In your XML; 在您的XML中;

     android:scaleType="fitXY" 
  2. In your Java code; 在您的Java代码中;

     yourImageView.setScaleType(ScaleType.FIT_XY); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM