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="QGRyYXdhYmxlL2hlYWRlcg==" />
这就是我的代码与图像的精确像素大小:
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="QGRyYXdhYmxlL2hlYWRlcg==" />
如您所见,这就是确切的像素大小:
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 大于实际像素大小?


- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01