Android screen size HDPI, LDPI, MDPI
You should read Supporting multiple screens. You must define dpi on your emulator. 240 is hdpi, 160 is mdpi and below that are usually ldpi.
Extract from Android Developer Guide link above:
320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).
480dp: a tweener tablet like the Streak (480x800 mdpi).
600dp: a 7” tablet (600x1024 mdpi).
720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).
Image resolution for mdpi, hdpi, xhdpi and xxhdpi
Please read the Android Documentation regarding screen sizes.
From a base image size, there is a 3:4:6:8:12:16 scaling ratio in drawable size by DPI.
LDPI - 0.75x
MDPI - Original size // means 1.0x here
HDPI - 1.5x
XHDPI - 2.0x
XXHDPI - 3x
XXXHDPI - 4.0x
For example, 100x100px image on a MDPI will be the same size of a 200x200px on a XHDPI screen.
Graphic dimensions for hdpi/ldpi/mdpi
Google suggests using
3 : 4 : 6 : 8 : 12 : 16
scaling ratios for
ldpi : mdpi : hdpi : xhdpi : xxhdpi : xxxhdpi
accordingly. Example:
- 36x36 for low-density
- 48x48 for medium-density
- 72x72 for high-density
- 96x96 for extra high-density
- 144x144 for extra-extra-high-density
- 192x192 for extra-extra-extra-high-density
In your example, if mentioned button sizes are for hdpi, correct dimensions should be:
- 150x45 ldpi
- 200x60 mdpi
- 300x90 hdpi
- 400x120 xhdpi
- 600x180 xxhdpi
- 800x240 xxxhdpi
android splash screen sizes for ldpi,mdpi, hdpi, xhdpi displays ? - eg : 1024X768 pixels for ldpi
There can be any number of different screen sizes due to Android having no set standard size so as a guide you can use the minimum screen sizes, which are provided by Google.
According to Google's statistics the majority of ldpi displays are small screens and the majority of mdpi, hdpi, xhdpi and xxhdpi displays are normal sized screens.
- xlarge screens are at least 960dp x 720dp
- large screens are at least 640dp x 480dp
- normal screens are at least 470dp x 320dp
- small screens are at least 426dp x 320dp
You can view the statistics on the relative sizes of devices on Google's dashboard which is available here.
More information on multiple screens can be found here.
9 Patch image
The best solution is to create a nine-patch image so that the image's border can stretch to fit the size of the screen without affecting the static area of the image.
http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch
how to know which phone support which layout(hdpi , mdpi and xhpi)?
Android treats mdpi (160 pixels/inch) as the base density. So for mdpi devices, 1 dp = 1 pixel. At higher densities, there are more pixels per inch (240 for hdpi, 320 for xhdpi).
AutoMatic Scaling by Android itself:
Android attempts to make graphic images occupy the same physical dimensions on the screen regardless of the device pixel density. So if all it finds is an mdpi resource, and the device is hdpi, it will scale the graphic by 240/160 = 150%, and it will double the size of the graphic for xhdpi.
Using different versions of graphics :
If you don't want this automatic scaling (which can make graphics look poor), you can simply supply your own version of graphic resources for use at higher densities. These graphics should be of the same size that Android would scale an mdpi resource.
Note : the pixels/inch that was stored in the image file has nothing to do with this. It's all based on where you put the graphics files in the resources directory for your project. Any graphics placed in res/drawable are assumed to be properly sized for mdpi displays, as are graphics placed in res/drawable-mdpi. Image files that it finds in res/drawable-hdpi are assumed to be properly sized for hdpi displays, etc. When your program runs on a particular device, Android will first look for a graphic that matches the display density of that device. If it does not find one but instead finds one for a different density, it will use that and automatically scale the image based on the above rules.
As the ldpi, mdpi and hdpi refer to screen density, which means how much pixels can fit into a single inch.
the ratio in pixels between them is:
ldpi = 1:0.75
mdpi = 1:1
hdpi = 1:1.5
xhdpi = 1:2
xxhdpi = 1:3
so lets take an image with about the size of 100X100:
for mdpi it should be 100X100
for ldpi it should be 75X75
for hdpi it should be 150X150
for xhdpi it should be 200X200
for xxhdpi it should be 300X300
this way, for screens with the same size but different DPI, all the images seem the same size on screen.
Sizes for drawable: LDPI, MDPI, HDPI, XHDPI, XXHDPI, XXXHDPI?
Inside Android Studio, if you right click on the res folder, you can select New > Image Asset which will create properly sized drawables for those dpi bucket folders.
Optionally, you can also use a website like this one: http://romannurik.github.io/AndroidAssetStudio/index.html
You can also programmatically change width/height, but this is heavily discouraged due to how disgusting a smaller image looks when it's stretched large. Only use this programmatic solution if you use vector images.
Related Topics
Android Calling Asynctask Right After an Another Finished
Android: Launch Activity from Clickable Text
How to Get Each Device's Ip Address in Wi-Fi Direct Scenario
Android 'Unable to Add Window -- Token Null Is Not for an Application' Exception
Two Textviews Side by Side, Only One to Ellipsize
How to Get References for All Currently Active Fragments in an Activity
Identifying Rtl Language in Android
How to Change the Background Color Around a Dialogfragment
Get My Phone Number in Android
Gridview with Different Cells Sizes, Pinterest Style
How to Merge Dex - Android Studio 3.0
Retrofit2.0 Gets Malformedjsonexception While the JSON Seems Correct
Android: How to Tell If the Soft Keyboard Is Showing or Not
Google Play Security Alert - Your App Is Using an Unsafe Implementation of the Hostnameverifier