score:0
These refer to screen pixel density, not screen dimension. You need to look into screen size specifiers like small, medium, large, and xlarge instead if you really need to change behavior based on screen size in pixels.
The Android docs explain what densities and sizes match these identifiers.
score:0
Android devices can have different width-to-height ratios, while your image has a fixed one. If you do not want your image stretched, you will have to fill the blank spaces above and below or left and right.
score:1
I support previous answers but don't forget the power of Draw9Patch or using NinePatchDrawables
score:3
I have found this online dip <--> pixels calculator very useful.
score:7
The definitions are:
- 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. (Android does not currently support screens smaller than this.)
Also, check out this blogpost from Dianne Hackborne: http://android-developers.blogspot.com/2011/07/new-tools-for-managing-screen-sizes.html
Probably the easiest thing is to use an image view and set the scaletype to CENTER_CROP. (Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or larger than the corresponding dimension of the view).
Make sure that you use the src tag rather than setting the background.
<ImageView
android:id="@+id/home_video_layout"
android:src="@drawable/splash_image"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
/>
Updated:
Understanding Screen Densities and the “dp”
Resolution is the actual number of pixels available in the display, density is how many pixels appear within a constant area of the display, and size is the amount of physical space available for displaying your interface. These are interrelated: increase the resolution and density together, and size stays about the same. This is why the 320x480 screen on a G1 and 480x800 screen on a Droid are both the same screen size: the 480x800 screen has more pixels, but it is also higher density.
To remove the size/density calculations from the picture, the Android framework works wherever possible in terms of "dp" units, which are corrected for density. In medium-density ("mdpi") screens, which correspond to the original Android phones, physical pixels are identical to dp's; the devices’ dimensions are 320x480 in either scale. A more recent phone might have physical-pixel dimensions of 480x800 but be a high-density device. The conversion factor from hdpi to mdpi in this case is 1.5, so for a developer's purposes, the device is 320x533 in dp's.
score:25
Install ImageMagick and use this shell script to generate your splash and icon files for multiple devices - iOS, Android, Bada and Windows Phone. You can use cygwin/gitbash if you are on Windows
I just did and I'm pretty happy with it :-)
The screen sizes are inside the script and are -
480x800 - screen-hdpi-portrait.png
320x200 - screen-ldpi-landscape.png
720x1280 - screen-xhdpi-portrait.png
320x480 - screen-mdpi-portrait.png
480x320 - screen-mdpi-landscape.png
200x320 - screen-ldpi-portrait.png
800x480 - screen-hdpi-landscape.png
score:76
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
- xxxhdpi = 1:4
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
- for xxxhdpi it should be 400X400
this way, for screens with the same size but different DPI, all the images seem the same size on screen.
Also you have multiple screen size types small, normal, large, xlarge and each one of them can be ldpi, mdpi, hdpi, xhdpi, xxhdpi (Nexus 10) or xxxhdpi.
You can try to create a splash screen image that fit to each and every screen type which gives you 4*5 = 20 different images (it seems to much for me).
For now only the Nexus 10 is at the xxhdpi category.
Source: stackoverflow.com
Related Query
- Android screen sizes in Pixels for ldpi, mdpi, hpdi?
- Eclipse Android layout designer - add new screen sizes for previewing
- Phonegap - add a splash screen for Android app
- Android Eclipse emulator problem: Runs WVGA(hdpi) as a mdpi screen
- How to use single drawable for all screen resolutions in Android programming?
- Good avd settings for testing large screen devices with Android SDK?
- Detecting Single Tap in Screen for Android
- How do i add new android screen for UI testing in Eclipse
- Android SDK for Eclipse - How to add 4.3 inch screen preview
- How do you create a title screen for an android app? E.g. When the app is loading like Facebook
- Android Loading Screen for AsyncHttpRequest
- Sample Android Launcher is in phone resolution and I need to edit it for a tablet screen
- Android App: My Manifest accepts all screen sizes but the Samsung GT-S6500D can't install it
- Android Different layouts for different screen resolutions
- Developing for Android in Eclipse: R.java not regenerating
- How to output messages to the Eclipse console when developing for Android
- Which Eclipse version should I use for an Android app?
- Typical .gitignore file for an Android app
- Enabling ProGuard in Eclipse for Android
- Benefits of switching from Eclipse to IntelliJ IDEA for Android development
- "Unable to get system library for project" after I upgraded to Android SDK 2.3 and ADT 8.0
- Can you change min. API level for your Android app in Eclipse?
- Android - "Parsing Data for android-21 failed"
- findFragmentById for SupportMapFragment returns null in Android Studio
- Why can't OSX detect android Galaxy S for USB debugging?
- Online radio streaming app for Android
- How to convert an Eclipse Android project to use Ant for build?
- Parsing data for Android L failed.Unsupported major.minor version 51.0
- Android AVD not showing anything. only "ANDROID" in the middle of the screen
- How to use Gradle to generate Eclipse and Intellij project files for Android projects
More Query from same tag
- Populate SQLite using XML and integrating inside Activity
- Android Emulator is not responding to program
- Eclipse's Content Assist does not work for java.util.Comparator
- Exception in thread "main" java.lang.NoClassDefFoundError in the eclipse
- Webapp does not load images
- How do I make a "proxy" class for a web service in Eclipse for Java?
- Loading TiledMap resource, within jar... about to make me go insane(Slick2d)
- Enable or disable File->New popup menu based on perspective change
- How do I know which variables exist in an object?
- Exception when trying to upgrade to sbt eclipse 4.0.0
- Batch script with eclipse: insert a string in file name
- svn update --ignore-externals w/subversive
- How can I check if eclipse is currently running?
- How to retrieve all dependencies from my project
- Put other things in eclipse workspace
- Eclipse Version differences
- OpenJDK 11 + OpenJFX 11 via maven fails to run inside Eclipse 2018-09 + Java 11 Patch
- How to do 'mvn compile' and 'mvn package' with m2e in Eclipse?
- Replace JS comments in eclipse
- Open pdf file with Eclipse
- debugging a Yii web application using Zend Debugger in Eclipse
- solve this error "The import java.util.Random conflicts with a type defined in the same file"
- Compilation error on Eclipse Indigo : javax.servlet.jsp.JspException, javax.servlet.jsp.PageContext cannot be resolved to a type
- Iterate through a list?
- an error occurred while installing eclipse
- Start listening to user selections on Eclipse start-up
- Incorrect Animation Rendering of Fragment transition
- Eclipse IDE Pydev Import Errors
- How to add a file as a link in Eclipse
- Why ECLIPSE NEON is so slow on ubuntu 16.04?