When I install and run application I see on the desktop large HDPI icon, but when activity starts, I see small MDPI icon. The icons have some marks to differentiate them, so I am sure what icons I see.
Layout:
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon"
/>
AndroidManifest.xml
<application
android:icon="#drawable/icon"
android:label="#string/app_name" >
...
Icons:
/drawable-mdpi/icon.png -> 48x48 px
/drawable-hdpi/icon.png -> 72x72 px
Display metrics:
DisplayMetrics{density=1.0, width=1280, height=752, scaledDensity=1.0, xdpi=160.15764, ydpi=160.0}
So, why does it take HDPI to display on desktop? And MDPI for my screens?
What is the physical size of your devices screen? I have a feeling your application is simply running in a screen compatibility mode. Otherwise, perhaps your packages resources are screwed up in some way. Normally cleaning the project in Eclipse will resolve that. If its the compatibility mode check this page for more information: http://developer.android.com/guide/practices/screen-compat-mode.html
Related
I was working on android app based on phone. However, recently the app need to support the tablet.
The design was based on 1920 * 1080, I put all images/ icons into the xxhdpi folder and for lower resolution I just let android to help me rescale it.
The problem is , it works well on phone(1280 * 800 5"), but when I use tablet to check it (say , galaxy tab 2 which resolution is only 1280 * 800 10.1" and 1024 * 600) but it looks like very blur . How to fix it ? Thanks for helping.
Added
<supports-screens
android:resizeable="true"
android:smallScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:normalScreens="true"
android:anyDensity="true"/>
already but still the same
Update: I also find that the dp is too small for the tablet
<style name="AppBaseTheme" parent="#style/Theme.AppCompat.Light">
<!-- API 11 theme customizations can go here. -->
<item name="android:actionBarSize">60dp</item>
</style>
I was using a custom actionBarSize , it works nice on phone, but the 60dp is too small for tablet, how can I fix it as well? Thanks
Well, I don't think you following the guidelines when you're using images. The android documentation doesn't say anything about screen resolutions when dealing with images, it rather focuses on pixel density when referring image resources (usually drawables) which is explained here. Remember that you can have two types of images (as far as I know):
Image resources (usually drawables)
Image assets
When using drawables you have to focus on pixel density rather than screen resolution because as you have just found out a small (or regular) screen device can have exactly the same resolution as a large screen device, to top it off, sometimes a normal screen device (handset) can have a higher resolution than a large screen device (tablet) where obviously in this case the handset has a much higher pixel density. So, you need to follow their guidelines take a medium pixel density (mdpi) device as the baseline to design your image resources as follows...taking a 96px image as an example...
for a medium density device (mdpi) provide an image with 96px in the drawable folder...this is your baseline
then, target a high pixel density(hdpi) device by multiplying your baseline image by 1.5...that is, 96x1.5 = 144px...place this image inside the drawable-hdpi folder with exactly the same name
a x-large pixel density device image would be the baseline image multiplied by 2 (96x2=192px). This goes inside the drawable-xhdpi folder
for an xx-large picel density (xxhdpi) device multiply the baseline image by 3 (96x3=288) and place it inside the drawable-xxhdpi folder
Notice in the link provided that you don't need to provide an image for a device with a low pixel density since Android scales it down from mdpi without any problems...
Note: Android also supports low-density (LDPI) screens, but you normally don't need to create custom assets at this size because Android effectively down-scales your HDPI assets by 1/2 to match the expected size.
In your case, whats happening is that your Galaxy tablet has a lower pixel density and Android down-scales the image from a xxhdpi to whatever density the tablet has (hdpi or xhdpi)....so, it your image is a 512px image Android would down-scale it to 341px for xhdpi or 256px for an hdpi device.
If you follow these guidelines and focus on pixel density, you should be fine. However, for images in the assets folder there's no much you can do apart from using the ScaleType enum or using stretchable 9-patch images
Hope this helps
Update
Actually, according to this link, the Galaxy Tab 2 has mdpi screen, which means your image will be scale down three times from xxhdpi. You should provide the same images with different sizes inside the appropriate drawable-x folders
I know its a way too late but recently I faced the same issue about the way app launcher icons looks on a tablet and they are blurry. I'm sure that AOS honestly chooses mdpi drawables for tablets with mdpi display density and thats the problem. So I solved this by placing smartphones icons to a tablet resources dirs as following (left column - usual smartphone drawables-density and the right - tablet dirs):
drawable-xhdpi -> drawable-large-mdpi (these are 96x96px)
drawable-xxhdpi -> drawable-large-hdpi (these are 144x144px)
drawable-xxxhdpi -> drawable-large-xhdpi (these are 192x192px)
drawable-xxxhdpi -> drawable-xlarge (these are 192x192px)
I'm not sure if last two has to be 288x288 px but since I don't have such icons in the project I guess 192x192 should be enough.
I read a lot about supporting multiple screens problems in Android, but I didn't solve mines yet. If I understood well, there are at least 2 ways to show images on different screens and to make it look normal. First, to make many images (xhdpi, hdpi, mdpi, ldpi). Second, is to create layouts(big, medium, small and etc.) My question is: which method is better? Now, my problem. I took first method, create my image in different sizes and copied to folders according to image's size. I used DEVS BITMAP app to get size, which I want my image to look like for different screens. I'm getting perfect view when I look on the 7' screen, but the view gets terrible on 3' screen. I copied this code to my Manifest:
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true" />
I think it isn't necessary, but I wanted to be sure I am doing everything good. Could anyone answer my question and solve my problem? I would appreciate your help! ;)
Create a new Project.
There is a layout folder ,values-sw600dp,values-dw720dp-land. In both these folders, there is a dimens.xml file. What is written in it is this :-
<resources>
<!--
Customize dimensions originally defined in res/values/dimens.xml (such as
screen margins) for sw720dp devices (`e.g. 10" tablets)` in landscape here.
-->
<dimen name="activity_horizontal_margin">128dp</dimen>
That mean folders with sw-720 dp are for 10 inch devices, similar 600dp are for 7 inch devices and default layout folders vary from 3 to 5 inch device.
layout-sw600dp -> This folder will have xml in PORTRAIL Orientation for 7 inch devices
layout-sw600dp-land -> This folder will have xml in LANDSCAPE Orientation for 7 inch devices. When you rotate your device, view will be formed from this folder
Based on the dpi/resoulution of your devices, you can create unlimited number of layout folders.
Similarly, there are folders for images called drawable ->hdpi ldpi mdpi xhdpi xxhdpi. Based on the resolution of devices, images are picked from their respective category.
xxhdpi will contain images with the highest resolution. So try to download big resolution images and downsize them and put them in the other folders.
Now how to know which device will take which image ? See the image below :-
See the drop down. It contains a list of devices with their resolutions and image type -hdpi ldpi mdpi xhdpi xxhdpi. Moreover, you can GOOGLE for the devices and their resolutions and dpi's.
So whatever app you are making for a device, choose that device and look at its resolution and see whether it is hdpi or ldpi etc. Accordingly, put the images and layouts.
This is my understanding. I create my layouts with this understanding. I hope you got a clear picture
For Multiple Screen Support
Add Different size of images to
drawable-ldpi/
drawable-mdpi/
drawable-hdpi/
drawable-xhdpi/
drawable-xxhdpi/
Suppose you have Imageview in layout folder
<ImageView
android:layout_width="#dimen/horizontal_len"
android:layout_height="#dimen/vertical_len" />
Do the following values
values/dimens.xml (Normal mobile)
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="horizontal_len">16dp</dimen>
<dimen name="vertical_len">16dp</dimen>
values-large/dimens.xml (7 inch)
<dimen name="horizontal_len">20dp</dimen>
<dimen name="vertical_len">20dp</dimen>
values-xlarge/dimens. xml (10 inch)
<dimen name="horizontal_len">22dp</dimen>
<dimen name="vertical_len">22dp</dimen>
So you have to try like this.
I'm having some issues in an App that I'm developping in Android:
We are creating an app with support for multiple screens, going from an Samsung Galaxy Ace to a Samsung Galaxy Tab 2 10.1, Supporting small, medium, large and x-large screens, but, somehow Android is not respecting my layout-xxxx folders. In Eclipse visual layout editor, when I Change the Screen it moves me to the correct folder, for representing that layout. But, In Android, Emulator or Real Device, the Layouts in their folder aren't displayed the correct way.
My folder structure is like the ones, mentioned at Android Developer:
res/layout-xxxx
res/values-xxxx
I've also read that since Android Honeycomb, somethings changed, the small,large,xlarge qualifiers became depecrated. So We created folders using layout-swdp, and we thought that would be the Solution for Devices with honeycomb +. But, soon we realized that this didn't work.
So, Is there a exact way to do this?. To make Android respect or force, these folders?.
Also, in Android 2.2 when using Dimens, the App didn't start. It tells that there's no dimen 0x01. Thank you In Advance.
Personaly I would use Screen pixel density (dpi) for each layout.
That is:
ldpi: Low-density screens; approximately 120dpi.
mdpi: Medium-density (on traditional HVGA) screens; approximately 160dpi.
hdpi: High-density screens; approximately 240dpi.
xhdpi: Extra high-density screens; approximately 320dpi.
Added in API Level 8
See http://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources
The folder should be:
values > Standard phone screen
values-sw600dp > 7" phone/tablet screen
values-sw720dp > 10" tablet
You have to initialize <dimen name="myvariable"></dimen> in the XML file within those folders and call inside your XML.
Example:
<Button
android:id="#+id/btnHome"
android:layout_width="#dimen/myvariable"
android:layout_height="#dimen/myvariable"
android:text=""
android:background="#drawable/homebutton" />
And it will resize based on the screen size.
I am working on my app and that ensures the size is same across all three screen.
hi good afternoon any ideas in how can i improve png quality of my icons? i used the kit from android developer page but i cant get sharp images i mean crystal clear, do i need to load this icons in a diff way than just draging into my layout? thanks
i use this layout:
<!-- Rightend Arrow -->
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/arrow"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"/>
</RelativeLayout>
for example you can see the right arrow icon in eclipse sharp but in emulator and device looks blurred:
You need to provide resources for all densities. If you just place one icon in res/drawable, that resource will be used and scaled for densities above mdpi. So for an hdpi device, you're going to see an upscaled (150%) version of your drawable, and for xhdpi, you'll see a 200% upscaled version of your graphic.
This is bad.
You'll need to create larger versions of your graphic using the 3:4:6:8 ratio, where mdpi is the density (4). You can mostly ignore ldpi, but just provide a fallback in res/drawable. Your icon for hdpi should be 1.5x larger, and your xhdpi icon should be 2x as large. So for instance, an image you want to display at 48x48dp (device-independent pixels) should be created at 48x48px for mdpi (placed in res/drawable-mdpi), 72x72px for hdpi (placed in res/drawable-hdpi), and 96x96 for xhdpi (placed in `res/drawable-xhdpi). Android will automatically pick the correct version for your density if you've made it available, and won't scale it.
Keep in mind, the graphics still will be only as sharp as you design them originally.
See this article for more information.
I use MobiOne software to author android apps and I ran into the same blurry icon issues when I was following the 36, 48, 72, and 96-pixel icon sizes rule. Guess what? I replaced the 96px one with 300px image and the resulting icon came out crispy and sharp when viewed on Samsung Galaxy S4. I later replaced the 72px one with 200px image.
I have created four versions of my launcher icon for ldpi, mdpi, hdpi and xhdpi devices. They are of dimensions 36x36, 48x48, 72x72 and 96x96.
I'm wondering what will happen when using a large screen. Consdering large screens are rouglhy 7" + in size a ldpi, large screen will surely not want a 32x32 icon image, located in a drawable-ldpi folder.
I cannot find anything on the dev guide that indicates what icon sizes to assign to large and xlarge devices. Presumably I would put a larger copy of the icon in the drawable-large and drawable-xlarge folder. However, I do not know what sizes to use. Does anyone have any recommendations?
Google provide an online tool called Android Assest Studio which creates the launcher icons in the correct size for you. http://android-ui-utils.googlecode.com/hg/asset-studio/dist/icons-launcher.html
A 7-10" tablet doesn't need anything unusually large. You don't need anything bigger than a 96x96 launcher icon for this use case. There is a table in the Launcher Icons section of the design docs that shows which sizes correspond to which densities.
Have a look at the Declaring Tablet Layouts section of the design docs for more info on how to organize resources for 7-10" screens. (Note that the resource used will depend on the screen density, it is possible that a 7" tablet will have an mdpi screen.)