为什么 wrap_content 大于实际像素大小? [英] Why is wrap_content bigger than real pixel size?

查看:44
本文介绍了为什么 wrap_content 大于实际像素大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图理解一些事情.我看到的一件奇怪的事情是,当我将 wrap_content 放入宽度和高度时,图像大于插入图像的实际 px(像素)大小.为什么会这样?

I am trying to understand something. A weird thing that I see is that when I put wrap_content in the width and hight, the image is bigger than the the real px (pixel) size of the image which is inserted. Why is that so?

我的 wrap_content 代码:

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:adjustViewBounds="false"
    android:src="@drawable/header" />

这就是我的代码与图像的精确像素大小:

and thats my code with exact pixel size of the image:

 <ImageView
    android:id="@+id/imageView1"
    android:layout_width="378px"
    android:layout_height="155px"
    android:adjustViewBounds="false"
    android:src="@drawable/header" />

如您所见,这就是确切的像素大小:

As you can see, thats the exact pixel size:

这是为什么呢?我认为 wrap_content 应该将视图包装到内容大小,为什么它在屏幕上更大?

Why is that? I thought that wrap_content should wrap the view to the content size so why is it bigger on screen?

推荐答案

http://developer.android.com/guide/practices/screens_support.html.

您需要在缩放后将图像放在相应的文件夹中.

you need to put images in respective folders after scaling.

例如如果你想要 100*100 的图像然后放置

e.g. if you want 100*100 image then place

75*75 in drawable-ldpi for Low density devices

100*100 in drawable-mdpi for medium density devices

150*150 in drawable-hdpi 用于高密度设备

drawable-xhdpi 中的 200*200 用于超高密度设备

这篇关于为什么 wrap_content 大于实际像素大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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