Why is wrap_content bigger than real pixel size?(为什么 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 大于实际像素大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么 wrap_content 大于实际像素大小?
基础教程推荐
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
