Got this really stupid problem:
Can find the proper name for the android folder for WVGA800 resources.
I've created a folder for WVGA854: drawable-normal-long-hdpi
It worked totally fine.
For WVGA800 I've tried 'drawable-normal-notlong-hdpi' - emulator and handset still gets resources from 'drawable', not even 'drawable-normal-long-hdpi'.
Tried using 'drawble-hdpi', 'drawable-notlong-hdpi' - nothing works, it keeps using 'drawable' for resources.
How should the folder for WVGA800 be named?
UPD:
Using
supports-screens android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"/>
Didnt solve the problem.
Is there a way to debug what resource folder is used and why?
Android is not like the iPhone. In iPhone it works to make full-screen images for the two supported resolutions, and rely on that. In Android, it doesn't work. There are too many resolutions, and more can come out any day of the week. The solution, then, is to really make the layouts and images device independent. Sometimes this requires creative solutions, but in any case it requires a change in thinking.
For example, we were trying to solve this same problem for a full-screen splash page. We had a logo, a gradient, and a set of objects at the bottom of the picture. The solution for us was to split these three things, allow the gradient to be stretched, and then position the logo in the center, and the objects at the bottom. This is the type of solution that is required in Android, and it will save you from having to cut a different graphic for every resolution.
You can also try nine-patch images for some of this. This would have worked great for our case except for the fact that the image included a gradient.
All seems correct, except you did a spelling mistake: "drawble". Check your directory names.
I suggest you try a more permissive resource filter first. Separate your assets in drawable-long and drawable-notlong, and see if it works.
Related
Sooo... I've come across a rather odd issue...
I am creating an app and need different versions of the layout for different devices. The default layout was made for my Nexus 7, so you can imagine it is quite large.
As recommended by the documentation, I created a layout-small folder in which I designed every Activity layout for a small device. So far so good, everything goes smoothly. I decide to change some buttons on my default layout as it will look better, but whenever I try to open it, it's display is of the 2.7''QVGA and whenever I try to change it back to the Nexus 7, Eclipse opens up my file from the layout-small folder! Damn it Eclipse! Let me choose what I open! When I run it, it still looks fine but this issue isn't allowing me to make any changes on what I have!
I already tried closing it and everything, but the damn small version of the layout keeps opening, over the default one!
Hope the issue is clear enough... I can see how it would be hard to understand.
Thank you very much for your time!
In your manifest, try letting the os know what sizes are supported by adding:
<supports-screens
android:smallScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"/>
Once you have this in your manifest, you can also use it to switch the use of various sizes on and off by toggling between true and false, to help test and debug your code.
Also, make sure that the changes you've made to your default layout are valid. If the changes make your default xml un-useable then one of the others may be used instead.
So, I'm making an app that has many different res folders for values, drawables and layouts.
The variation is by screen size, mobile country code (I'm using this field to override it and thus enable different skins in my app, much like iOS targets), landscape / portrait, screen widths, languages & dpi.
One of my biggest problems for this app is the fact that I need to support both tablets & phones. I create a layout for phones under layout-normal. If I do this, it seems like I must copy-paste my tablet layout into both the layout-large & layout-xlarge folders. If I don't, the app defaults to the normal layout.
I was wondering if there was a way in Android to override the way the runtime determines which folder it goes to. This way, I could via code, direct the run-time to the correct folder depending on the device's configuration, and not need to copy-paste my layouts all over the place.
Note:
I specified 1 reason I want to do this, but there are also several others. I'm looking for a way to override the way android determines which res folder it goes to, not a different solution to the 1 problem I specified above.
Any advice would be greatly appreciated!
In order to avoid the duplication you could use the resource alias mechanism as described here. That system can be used for images, layouts and other resources from the values folder.
Selection is done based on device configuration as explained here so if you could find a way to alter device configuration then it will work. But it will effect other apps as well. There are apps that allow you to change your device modes. There are custom ROMS that give this ability e.g. Paranoid ROM
I need to make sure my Android app works on all Android phones. How would I go about making sure that it works on all of them?
In my xml files I only use fill_parent and wrap_content and for layout I use LinearLayout. In my app I download some images from the web, save them to sdcard, and then display them. When an image is selected I play a video from the sdcard.
That's my app. Will it look the same on all android phones?
If not, what should I do?
The only thing you can do to check this is test your application on as many devices/emulator-configurations as possible.
If you are concerned if you app will look good on all Smart-Phones and Tablets, you can create multiple Android-Emulators to test it.
Further information about how to optimize your app for multiple screens can be found in the docs.
Be aware that not all the android devices have an sdcard, an surely lot of them have the sdcard almost full.
I think the application must work and see alright in all the devices (be sure to test with the emulator all the pixel densities) and also take care in the cases that the android doesn't have the sdcard.
For this condition there are two things
1) you have to write small code in you manifest file after ending of application tag
</application>
<supports-screens android:smallScreens="true"
android:normalScreens="true" android:largeScreens="true"
android:anyDensity="true">
</supports-screens>
2) If you are giving height and width of any widget (i.e. button or layout) in size such as 40px or 40 px etc change this thing into DIP(Device independent pixels). Use Layout:weight to make layout fixable to every screen. android:gravity or android:layout_gravity to fix layout to any place. and if you want to make fix it at particular position and linear layout in not help full use relative layout
Relative layout and always use DIP is way to make it work on all devices. However one warning, don't always trust the emulator, I designed and tested my app all on the emulator, however when I moved it to phone and my workmates, it was different on both our phones, so be careful
You need to define supports-screen inside the AndroidManifest.xml file.
And if you are selecting a version you could use android:minSdkVersion &
android:targetSdkVersion.
I'm looking for a system-wide graphic that (I think) is in android.R.drawable. I am looking for this one:
I realize that graphics differ between systems, however I am fairy sure that it is system wide because I have seen it in multiple programs.
I want to use the one Android provides so that my app looks good no matter what phone it runs on. Does anyone know where I can find that image to use in my program?
Taking a look at Android R Drawables, it seems it might be expander_ic_minimized.9
You can find those images in the Android SDK directory under
platforms/android-X/data/res/drawable-Ydpi
where X is the version code of Android and Y is the resolution (l/m/h). Most images are in the mdpi folder.
It is recommended to copy the images to your App, as the Android developers do not guarantee that all images will be there in future releases.
The image you are looking for looks like
expander_ic_minimized.9.png
TOPIC Solved: Answer below.
Some users have been reporting border alignment issues on some android components such as the alert popup or the editTexts. This is happening on the Samsung Galaxy Apollo (200x400) and the HTC Pro Touch (480x640) devices. I cannot replicate that because i don't own those devices and in the Samsung Galaxy S and emulator everything looks just right.
I think that the problem is the dpi or resolution of the device (because the edittext background is a single .9.png so image should look ok); however I am not sure if the supports-screens tag is the solution. Also, application was developed using Api 3 (v1.5) and supports-screens was not yet supported, nor the screen-size resource qualifier.
The style used for the alerts and editText is the phone default. Could the problem be something related with the theme applied to the phone by the user?
Thanks in advance!, I show some images given to me showing the problem:
It might actually be the display density causing this. If you don't provide assets in the appropriate density, the framework will try to rescale your images, including 9patches. Unfortunately there's no real perfect way of resizing 9patches and it can sometimes lead to artifacts, although I would be very surprised if it caused the type of artifact you are seeing.
I've had the same problem and the solution was changing the font size of the TextView from 16px to 17px (or any other odd number).
Well it really was the resolution/density. I managed to create an emulator with the WQVGA density (which needed > Android 1.6) and replicate the error.
The solution is seen on the Supporting Legacy Applications section of the Android Developers webpage: http://developer.android.com/guide/practices/screens_support.html. So a newer version of the API is needed in the project but it still holds support for the 1.5 version.
Thanks.