安卓:背景图片/ ImageView的不同的屏幕 [英] Android: Background image / imageView for different screens

查看:174
本文介绍了安卓:背景图片/ ImageView的不同的屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想一个背景图片设置为我的活动。我只是用一个相对布局的ImageView的和我想他们的其他元素的位置。现在,我们有一百万,或者至少是相当多的,不同的屏幕大小和密度。我不知道如何能实现其所有这些设备正确的图像。

I want to set a background image to my Activity. I am just using an imageView in a relative Layout and position the other elements as I want them. Now we have a million, or at least quite a few, different screen sizes and densities. I wonder how I can achieve having the right image for all these devices.

我不希望缩放/伸展我的形象。

I don't want to scale/stretch my image.

图片是一种方式,它是可以说2000×2000像素(或任何你喜欢),显示了这个形象的一部分,它无关紧要。换句话说,我可以在任何需要的图像大小裁剪出这个超大的形象,只显示部分。

The image is in a way that it is lets say 2000 x 2000 pixels (or whatever you like) it doesn't matter what part of this image is displayed. In other words I could crop any needed image size out of this extra large image and display only that portion.

我怎样才能做到这一点?

How can I achieve this?

谢谢,
一。

推荐答案

只要设置你的图像视图的android:scaleType =中心,它不会缩放或拉伸

Just set your image view android:scaleType="center" and it won't scale or stretch.

看一看在以下链接scaleType选项。这给你控制权的图像的呈现一个像样的数目。
http://developer.android.com/reference/android/widget/ImageView.ScaleType.html

Have a look at the scaleType options at the following link. This gives you a decent amount of control over how an image is rendered. http://developer.android.com/reference/android/widget/ImageView.ScaleType.html

也有看看下面的链接。可以提供资源与不同的文件夹相同的文件名称,并且系统将选择最合适的。这样,你就可以知道或多或少你与每个图像瞄准什么尺寸的屏幕,你可以在一个大小将执行至少裁剪(或可能不裁剪所有)创建的图像。
<一href=\"http://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources\" rel=\"nofollow\">http://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources

Also have a look at the following link. You can provide resources with the same file names in different folders, and the system will choose the most appropriate. This way, you can know more or less what size screen you are targeting with each image and you can create your images at a size that will perform the least cropping (or possibly no cropping at all). http://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources

这篇关于安卓:背景图片/ ImageView的不同的屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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