I have written an app that required me to create the following additional folders in order to support multiple screen sizes: layout-land, layout-small-land, and layout-small-port.
When I load an AVD for a QVGA screen, the emulator is loading the screen sizes from the HVGA settings, and I need to know how to force the emulator to load the correct files. I know it's loading the incorrect files because initially when I loaded the QVGA AVD, all of the text was too large, so I spent a few hours adding new versions of all my activiti files to the layout-small-port folder, then I retested and saw normal-sized text for the QVGA screen, and then I turned off my computer. The next time I turned on the computer and loaded the app in the QVGA AVD, suddenly all of the text on screen was super-small and barely readable. So, I proceeded to delete all of the new files I had just added to the layout-small-port folder and re-ran the QVGA AVD, and all of the text appeared correctly.
This morning I have loaded the QVGA AVD again, and once again the text is too large. Before my latest round of updates, the data in the QVGA screen had always appeared correctly, but now everything from the menu sizes to the text on screen is not being scaled to QVGA-sizes.
Do I need to re-add all of those screens for layout-small-port, or is there something going on in the emulator that I can fix?
I have set the text sizes in the affected activities using "dip" (i.e. 10dip). In my Android Manifest file, I set minSdkVersion=3 and targetSdkVersion=4 so that people with Android 1.5 can still download my app. My app is built against Android 1.6.
You might want to check this out:
http://blog.blundell-apps.com/emulator-settings-for-each-android-density/
It explains how to set the emulator for different density buckets (ldpi, mdpi .. etc) these are much easier to user than layout-large (which I believe is being deprecated anyway)
Related
I'm having trouble understanding this weird behavior. In my "Android Virtual Devices" settings, I had two devices that are both 8.0-inch tablets with 800x1280 screen resolution. However, one is categorized as "tvdpi" and the other one is categorized as "mdpi". The only difference is that the "tvdpi" device was created earlier (in Android Studio 2.1 or something) and the "mdpi" device was created in Android Studio 2.3.
This has created a problem where I can't see what the final layout will look like in the layout editor. When I ran the app on my real device, it's running a layout same as the simulated layout in the "tvdpi" device, but not the "mdpi" device. I'm afraid that if I delete the "tvdpi" device, I will never get it back and my layout editor will forever look different from the real device.
Because they are not the same device. Note the name column, both devices are called different. They may have the same physical screen size. But the density of each one is different to the amount of pixels.
I submitted a bug report to Google and it's being worked on.
https://code.google.com/p/android/issues/detail?id=246595
I am pretty new to Android and I am doing a pet project in order for me to learn Android. Basically I want to display six images on the screen. I have noticed the drawable folders and I have 256x256px inages in the drawable-xhdpi folder. In the Nexus 5 preview in android studio it looks great but in Nexus 7 (2012 version) the images are very small and both Nexus 5 and Nexus 7 are using the drawables-xhdpi folder.
This is my code:
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imageMars"
android:id="#+id/imageJupiter"
android:src="#drawable/jupiter"
android:contentDescription="#string/content_desc_jupiter"
android:layout_toRightOf="#+id/imageVenus"
android:adjustViewBounds="true"/>
How can I make the images look bigger on the Nexus 7, but without being to big for the nexus 5?
And I want the application to look good on other devices too, so I don't think that setting a fixed size for the image(70dp x 70dp for example) would work
Thank you
Best practice in Android is to provide the correct size images in each of those folders and let the system choose the best one based on the device. Supporting Multiple Screens is a must read.
Basically what happens is the system will navigate to the folder that would best satisfy its screen, if the image it needs is there, great; if not it will navigate to the next best folder and so on. If it cannot use the best for the device it will use the best you gave and try its best to make it look as good as possible. Sometimes this isn't so great. It can stretch or shrink images into an ugly state.
So again, the best thing to do is provide multiple sizes of the same image in each of the folders to get the desired results.
Edit (response to commentary):
Guess not. In Eclipse/ADT I've got
Nexus 4 # 768x1280 - Normal xhdpi
Nexus 7 (2012) # 800x1280 - Large tvdpi
So regardless of "larger" the fact remains that they're pulling resources from different drawable folders. The tvdpi is said to be not needed in most apps because it's somewhere between mdpi and hdpi and those folders are usually sufficient. Maybe add the tvdpi and see if it varies at all and make sure you've correctly scaled your images based on the folder.
Edit:
Alright, the behavior you're experiencing is normal - unfortunately I suppose - but I found a solution. I've personally never faced this because I learned it's better to utilize the extra area on larger screens to put more content on there.
Anyway, as if you didn't have enough drawable folders, you need another drawable folder, or three, along with more images - yeah!
In my previous edit I mentioned the "Normal" and "Large" modifiers of the drawable folders as they appear in Eclipse ADT. Well, it turns out that those are valid folders as well and certain devices with small, large, or xlarge screens will use them.
I was able to get larger images by adding another res directory titled drawable-xlarge-xhdpi; this is for the Nexus 10. I enlarged your jupiter file to 512x512 and...
Note: I read that this isn't a recommended solution but could not see anywhere in the Android docs that warned against it. Research may be necessary!
You should provide different image sizes for different display sizes/resolutions. That what the drawable-100w, etc folders are.
If you don't want to do that but you still want the images resized to use all the available space, you will have to do resize the ImageView elements programmatically.
I created custom device with configuration- screen size 5.3 inch and 900x1480 resolution.
Then i created AVD with different OS versions, but emulator never launches. It shows up emulator screen but all the time there is only black screen, not even showing "Android". In DDMS LogCat there are going on some actions but for me it looked like its one big loop repeating.
Also i tried to emulate HTC One (normal-xxhdpi) but there is same problem. In this case it may be there isnt updates made to support xxhdpi.
that happen to me if i set more than 786MB in RAM you should use 512 MB and the emulator will launch
Try selecting "Use Host GPU" in the virtual device settings.
I am developing android app which has lots of images. It's a korean app.
I want to support maximum number of resolution possible.
So I created 4 different folder(ldpi, mdpi, hdpi, xhdpi) for drawable as the google doc stated.
Now my problem is that my app work on all most all device perfectly but In korea there is device Pantech Vega LTE M which is giving lots of trouble
It's resolution is of xhdpi category but still in this device my app shows images from mdpi and it show bigger than it resolution. So half of the image is displays compressed.
So I am not getting how to set the drawables for this device. Do i need to add separate drawable folder to match this resolution.
If i changes the images in mdpi folder than it will create problem for other resolution.
Beside how many folder I need to add make my app compatible with every possible resolution available.
Thats because that device runs Android 2.3 Gingerbread where the X-Large configuration was yet not supported since that resolution was supported beginning with Adroid 3.0 afaik.
Edit:
Looks like the xhdpi was supported since API level 9, and the configuration specs from your device looks like a normal - large screen with xhdpi. So the only workaround that I could think of is creating those folders within your drawables.
Some of users downloading my apps complain that they were unable to install the app as it exited with MainActivity.class layout not being found. After investigating, I realized that those mobile phones have unusual screens.
For example, one of those phones is HTC ChaCha which screen is 480 x 320 pixels, 2.6 inches (~222 ppi pixel density). According to these specifications, it is a Normal screen, MDPI.
However, as its screen is set in the landscape mode (wide mobile screen), Android does not recognize it as Normal MDPI, but as something else and then it tries to pull XML layout from /layout dir. The Main.xml layout in this directory does not envisage such unusual screens and the layout gets broken (layout icons too big and probably pulled from HDPI drawable directory).
How to make the XML layout for such unusual phones?
PS. One more Question. When I create an emulator for this phone via Android SDK Manager, should I set "Abstracted LCD density" to 222 or keep it to 160???
The problem of the HTC Chacha is in fact it's screen aspect.
It's a "notlong" screen (like the HTC Wildfire if I'm correct).
To make a specific layout for this phone (and all screens with a 4/3 ratio), just make a layout in layout-notlong directory.
res
|---layout-notlong
|----mylayout.xml
Are you sure that the error is that the activity's class can't be found?
Several device vendors will incorrectly describe the density of their screens. The density is not derived from the physical size and pixel count. Some have done this for compatibility reasons; for instance, the original Samsung Galaxy Tab (released before Honeycomb, therefore not technically "tablet ready") reports itself as HDPI so that graphics and layouts are selected to make it use the screen more like a phone.
In regards to your layouts, if you have a decent default (in res/layout/) this will be chosen if no more specific layouts are available (e.g. res/layout-land/ or res/layout-large/). Keep in mind that each of the view ids that you reference in code must be available in all layouts. Keep them all up to date with each other or you will end up with inconsistent behaviour.
If you're diligent about making graphics for at least the main three densities (ldpi, mdpi, and hdpi) then you should not see over-large icons except where the screen is physically smaller than your layout expects it. Also, use dp in your layouts instead of px.
Perhaps the good start to identify the problem is to check the Application Error Reports
in your android market publisher account.
Click on Erros(2) just next your app in the apps listing.