I have an ImageView
with these attributes:
android:layout_width="match_parent"
android:layout_height="160dp"
UI developer asks me for the size of Image that I want in px. What size should I ask? Should I ask different size for different devices?
Note
I don't have an ImageView
with specific height and width. My ImageView
width is match_parent
not a specific width.
All the answers say that I should use a converter, How can I convert match_parent
to px
?
According to answers, I should ask about six images, shouldn't I?
2500 pixels width is ideal in most cases. You don't need to resize your images if they're wider than 2500px and meet our other specifications. Images less than 1500px wide may appear blurry. We suggest different widths for site logos, browser icons, email campaigns, and animated .
When saving images for the web, we recommend the file size should be less than 2MB (2048 kilobytes) to maintain fast page loading speeds. That being said, we also want images to be sharp and not pixelated.
On mobile devices, images get resized by the browser anyway, and that 1500px size is enough to look crisp on smartphones with high-PPI “retina” screens too.
2400x1600px, jpeg, saved for web, and optimized To ensure that your full width images look good across any device big or small the recommended size is 2400x1600px. Note that devices have different ratio than the one you shoot and it is possible your images will be cropped when viewed on web.
You should give highest screen density in pixels to your UI developer then scale to lower densities on your own.
Normally an android app will support screen densities ldpi at min and xxxhdpi at max.
Step1: If you want the image size is 160 x 160 dp
then give the UI developer the highest image size associated with max screen density.
160 x 4 = 640x640 px (why multiply by 4? I will explain later)
Step 2: Scale the image 640x640 px
to lower size based on screen densities
Tips: Find your image size corresponds with mdpi density screen (known as base density
or 1X
density) then scale to other densities by the following formula
Update: From https://material.io/tools/devices/, screen size for base density screen is 360x640 px
. So your ImageView
size will be 360x160 px
on 1X
density screen.
ldpi: 270x120 px
mdpi: 360x160 px
hdpi: 540x240 px
xhdpi: 720x320 px
xxhdpi: 1280x480 px
xxxhdpi: 1440x640 px
Why are you not using Vector drawable?
Why use Vectors?
You should use SVG images in your project.
Create SVG instead of PNG files
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With