简体   繁体   English

如何使图像适合 android 中的所有不同屏幕? 我需要 440x300dp 的图片,查看我的截图

[英]how to make images fit in all different screens in android ? I need images with 440x300dp,check out my screenshots

how to make images fit in all different screens in android?如何使图像适合 android 中的所有不同屏幕? I need images with 440x300dp and I created mdpi etc folders to place images,check out my screenshots and help me to solve this one我需要 440x300dp 的图像,我创建了 mdpi 等文件夹来放置图像,查看我的屏幕截图并帮助我解决这个问题

I need images to fill match parent of width and height should be 300dp but these mdpi,hdpi..etc not having it, I'm confused我需要图像来填充宽度和高度的匹配父级应该是 300dp 但这些 mdpi、hdpi..etc 没有它,我很困惑

在此处输入图像描述 enter image description here在此处输入图像描述

在此处输入图像描述

Thank you..谢谢..

if you need ImageView with fixed size then just use fixed size如果您需要固定大小的ImageView则只需使用固定大小

android:layout_width="440dp"
android:layout_height="300dp"

DON'T use layout_weight / weightSum params at all, with it you won't ever achieve what you want.根本不要使用layout_weight / weightSum参数,用它你永远不会达到你想要的。

and after that use android:scaleType param to fulfil your View .之后使用android:scaleType参数来满足您的View check out THIS visual tutorial for picking proper type查看视觉教程以选择正确的类型

laso all your drawables should have proper ratio, eg mdpi drawable may have 440px x 300px, hdpi x1.5, so 660px x 450px, xhdpi x2 and so on.所以你所有的drawables应该有适当的比例,例如mdpi drawable可能有440px x 300px, hdpi x1.5,所以660px x 450px, xhdpi x2等等。 some nice tutorial about density buckets in HERE一些关于密度桶的很好的教程在这里

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

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