Android design button for mdpi - android

I know it is a common problem but I didn't find the solution. When designing buttons for android you have to design for specific DPI but with MDPI there is a problem;
The smallest mdpi is 320x480, so i created the button to fit the smallest screen, but if u see at the 5,4 device which is mdpi to it is 480x854. The buttons looks to small for that screensize but i can't make them bigger because they don't fit on the 320x480 screen anymore?
Is there a an other way to make the buttons fit the screen? For tablet it also uses the mdpi images so it looks very tiny..

After searching a bit longer I've found the answer:
U have to add
drawable-large-mdpi
as folder to the res, and place the buttons there

Related

Android Splash Screen sizes (in px, to fit all devices) [duplicate]

This question already has answers here:
Android splash screen image sizes to fit all devices
(11 answers)
Closed 9 years ago.
I'm not new to Android app development. I have already created few apps with very simple UI where I didn't have to worry about screen resolution / dpi / dp... But today I have to create a more advanced Android app with a custom UI design (very "graphic").
I want to implement a splash screen (with an image in full screen). It's difficult and tedious because with Android we have to deal with a lot of resolutions and densities.
My problem
I have no idea what size to put in every drawable folder (ldpi, mdpi, hdpi and xhdpi).
What sizes (in pixels) should i create so the splash displays nice on all screens? Concretely, what files I need to create?
Few remarks
I know there are many other topics on StackOverflow (here, here or here) about Android splash screen / resolution issues. But none of these, in my opinion, gives a understandable / clear answer (I mean, with px).
I have read "Supporting Multiple Screens"
I'm aware of ratio between the densities:
ldpi (0.75x)
mdpi (baseline)
hdpi (1.5x)
xhdpi (2.0x)
xxhdpi (2.5x)
I'm aware of the 9-path image solution but it's not applicable for what I want (a full screen picture).
Tool like this one is helpful to converting dp in px
I have decompressed many APK files to see how these applications deals with splash screen images. None use the same size, it's confusing!
I do not need landscape splash screen.
With a 800x1280px PNG file (in xhdpi) it OK on my Nexus 4 emulator but verticaly stretched on Galaxy S4 emulator.
Like you already pointed out, the case you want to use as your reference frame is mdpi device. You need to make sure that you're happy with how your splash screen looks on mdpi device, and the Android will automatically re-scale your drawables for you, as long as you use .9.png (9-patch image) format and that the device has same aspect ratio.
For more information on 9-patch format, click here.
There is no single aspect for android screen, so there is no perfect solution for showing splash screen. You just need to put your image into some layout and display it as separate activity. Take a look for ImageView and scale property:
http://developer.android.com/reference/android/widget/ImageView.ScaleType.html
There is no universal solution for all cases, but try something like that:
put RelativeLayout as base layout, set match_parent for both height and width
put ImageView at center of it, set match_parent for width, wrap_content for height, try scale mode for getting satisfying result.
You can set background drawable for the base layout to fill up margins with some plain color or gradient.
Once you get the correct scalling try how it looks on smaller screens supply other resolutions to avoid excessive downsampling.

Do I need to design background for each device size?

Dear All I’m going to work in android application I should design the interface. I read articles on http://developer.android.com/design/index.html but I still have some missing point.
Do I need to design back ground for each device size ?
Check for this Link for supporting multiple screen. This link will show you how to create the different layout for different screen size devices.
But even if you want to make a Unique layout for supporting multiple screen in orientation or portrait mode then,
For image, use 9 patch images.
Here is the link http://developer.android.com/tools/help/draw9patch.html
For width and height of any widgets, use wrap_content or match_parent or you can use android:layout_weight and android:weightSum
Avoid using the pixels i.e. px
Use dp
By this you can create the unique layout working for multiple screens, but that screen should be in orientation or portrait mode.
If you want to support for for both,then you have to createlayout-landfor landscape mode in the res folder.
Actually, you should. There are 4 main screen sizes in android those get layout xmls from res/layout-xlarge, res/layout-large, res/layout-normal and res/layout-small. At the same time, you should use different image resolutions for different screens those get images from drawable-hdpi, drawable-xhdpi, drawable-mdpi and drawable-ldpi.
It depends on the background type. If your background is an image with high resolution you should provide different images for different screen sizes if the whole background is an image.
You can also:
Make background from tiles (like icloud.com)
Specify a ninepatch image if your image is something like a frame where corners should remain the same and the body should be scaled (not very good if you have some picture)
Specify multiple different images for different screen resolutions and densities. To do so read supporting multiple screens. If you need even more precision in image scaling and quality you can use the fundamental size of screen attribute which is sw<N>dp - you can specify the smallest width of the screen where your image should be used. This is a qualifier name for a resource folder.
Some values you might use here for common screen sizes:
320, for devices with screen configurations such as:
240x320 ldpi (QVGA handset)
320x480 mdpi (handset)
480x800 hdpi (high density handset)
480, for screens such as 480x800 mdpi (tablet/handset).
600, for screens such as 600x1024 mdpi (7" tablet).
720, for screens such as 720x1280 mdpi (10" tablet).
You should also have a look at other qualifiers that make Android choosing image at runtime (screen density, Available width, Available height, Screen size or Screen aspect). By combining these qualifiers and testing carefully you will be sure that the user has the best experience on each device.

Android one icon for all small - large screens, will it display?

I have a quick question: will it work when I put the same 57px x 57px icon to all drawable-ldpi, drawable-mdpi and drawable-hdpi folders. Will it run on all devices?
in other words if small icon will be visible on big screens or x-large screens.
It will work, but you really should not use size of 57x57 for any screen size - scaled down images will look as ugly as scaled up. Better avoid it.
Please read more here: http://developer.android.com/guide/practices/ui_guidelines/icon_design_launcher.html (yes, it is an official documentation).
Yes, it'll work. But it is good to have all icons. Because it'll be pixelat on large screens.
If you simple put icon in drawalbe folder (which is default folder) and you don't have any other folders like hdpi, mdpi, ldpi for all screen sizes. then it'll also be considered for all resolutions/sizes.
It will work. But it will not look well on some screen.

How should I provide alternative resource for qHD(540x960 resolution with 256 dpi) screens

I have designed attached screens for my app. The app targets android 1.6 and above. Currently the app is running on majority of hdpi and mdpi devices and few devices having some odd resolution like 1024x600 with 169 dpi, 1024x600 with 179 dpi, 1024x600 with 240 dpi. I have provided alternative layouts to support multiple screens in below mentioned folders.
layout: Default layout resources.
layout-hdpi: For hdpi screens. Few layouts in my projects need to be specifically optimized for this.
layout-mdpi: For mdpi screens. Few layouts in my projects need to be specifically optimized for this.
layout-large: Default layout resources for large screens.
layout-large-hdpi: Layout resources for hdpi screens having resolution 1024x600
layout-sw400dp-v11: This is mainly for 7" tablet. Only devices running Honeycomb or above can recognize this.
Now I also need to add support for qHD screens(540x960 having 256 dpi or similar). Below is the example screen I need to design and add support for qHD screens. This screenshot is taken on HTC Incredible S having resolution of 480x800 with 240 dpi.
I have designed layout for qHD screens so that it will look same on those screens as well.
Now, I have below questions:
1. Am I having right directory structure for providing alternative resources considering I need to support hdpi, mdpi and above mentioned odd screens? If not, how should I provide alternative resources as for those screens? I really need to design separate file so that the UI looks the same across multiple screen resolutions and densities.
2. qHD Screen are having 256 dpi. That means those screens are hdpi screens. I already have resource for hdpi screens which looks as above on most of the devices. but when I view it on qHD screens, it looks like below screenshot. So, how do I provide alternative resource for qHD screen such that it won't affect my current layout resources which are showing good on most of the devices?
#Espiandev
A qHD, hdpi device has a display-independent pixel (DIP) screen size of 360x640, whereas the Incredible S's is 320x533 hence why some of the images are higher up the screen relative to others. So essentially, the qHD device can show more stuff that the Incredible S, per screen. See here for an explanation of DIPs and some more tips
-- Thank you for this insight. I am aware of this. Also I have read post by Dianne Hackborn,; "New Tools For Managing Screen Sizes" - http://android-developers.blogspot.in/2011/07/new-tools-for-managing-screen-sizes.html
From what it looks like, you're currently using some margin or padding above the goal/gain/to go parts, I'd instead suggest changing their gravity to bottom (i.e. align them to the bottom of your screen) and then use a margin or padding below the item.
-- No I am not using padding or margin for these parts. Its a relative layout where goal/gain/togo buttons are below that meter tape button. As you have suggested setting gravity to bottom and have bottom padding; yes, I had tried that as well but then distance between that meter tape button and these circles increase and I have to modify sizes and margins between those glasses, button below that and meter tape button which created different layout file. When you view this screen on small screen devices, views will overlap as small screen devices can show less views.
But I'd work on making your app adaptable to screens rather than trying to divide screen sizes up like this, as you shouldn't really need separate layout resources for mdpi, hdpi etc.
-- I agree that Normally I shouldn't need separate layout for mdpi and hdpi screen. But the requirement here is that screen should look exactly the same on all screens. Like, all views within that yellow circle should not go outside of that circle. That button at the center should be always at the center. Also, the relative sizes of those 3 little circles at the top and below meter tape button should be same. This left me no choice than creating different layout for mdpi and hdpi screen.
I have created different layout file for qHD screen. Now my question is where do I put that so that qHD devices will use that file and other devices will continue to work as those are working now.
A qHD, hdpi device has a display-independent pixel (DIP) screen size of 360x640, whereas the Incredible S's is 320x533 hence why some of the images are higher up the screen relative to others. So essentially, the qHD device can show more stuff that the Incredible S, per screen. See here for an explanation of DIPs and some more tips.
There's no real way to make the UI look exactly the same on the Incredible S and qHD devices. Unlike iOS devices, screen sizes are very varied. From what it looks like, you're currently using some margin or padding above the goal/gain/to go parts, I'd instead suggest changing their gravity to bottom (i.e. align them to the bottom of your screen) and then use a margin or padding below the item. That way it will hopefully stay aligned with your lunch/dinner boxes. If you post your XML file, that will help diagnose the problems.
Before Android 3.2, I don't believe there is a way to distinguish the two cases above, but after 3.2, you can use the swXXXdp (shortest width) attribute. But I'd work on making your app adaptable to screens rather than trying to divide screen sizes up like this, as you shouldn't really need separate layout resources for mdpi, hdpi etc.

Android: Maintaining image resource size

I know there are tons of questions on this topic, but I tried searching through tons of "android dpi" posts and read the online documentation but haven't found the exact question that I have.
If I want to create a button (or any image resource) that will take up the same space on the screen on all devices - how do I do that?
I understand that there are specific screen sizes and dpi's that Android looks at etc. but I don't quite understand how big a specific image should be to look right on any screen.
Say that I have the following setup for my drawable and layout folders (Application is only landscape):
res/drawable-ldpi/button.png (120 dpi)
res/drawable-mdpi/button.png (160 dpi)
res/drawable-hdpi/button.png (240 dpi)
res/layout-small/main.xml - button is set to 100dp
res/layout-normal/main.xml - button is set to 100dp
res/layout-large/main.xml - button is set to 100dp
Say I have a button that I want to be 100dp on any screen. Following the 3:4:6 scale ratio rule it seems that if I have a button resource that's 100px wide for the mdpi density I should make another button for the ldpi density that's 75px, and one for the hdpi density that's 150px. Is that correct? Do I create the 75px button at 120dpi, the 100px button at 160dpi and the 150px button at 240dpi and then just say android:layout_width="100dp" in all three layout files? Or do I make all three buttons 100px at the different dpi's?
Now what if I have that button 9 patched. Do I have to create the button three times at 120dpi, 160dpi and 240dpi all of which are 100px in size? Or do I just create one 9 patched button at 100px and 160dpi and place it in the mdpi drawable folder?
The online documentation is a bit confusing for me so I'm looking for a simplified answer.
This is for Android versions 1.6+ (Not the new stuff for 3.2 etc)
Thanks for your help ... I just want a button to take up the same space on a 3.7" screen as a 7" screen and not be blurry!
Did you sort this? Afaik, and from my experience, don't change the dpi when creating the images in say, Photoshop. I always left mine at standard which is 72 I think. Regardless, I don't think it matters if you set it to a million.
The px values you mentioned are correct for l m and h.
I would leave the mdpi qualifier off the folder name though; I'm unsure of the protocol if on an xhdpi device there is no drawable folder with no xhdpi qualifier and no folder without qualifiers.
Workflow:
Create your images at 75, 100 and 150.
Put 75 in ldpi folder, 100 in drawables folder with no qualifier, and 150 in hdpi.
Leave your layouts as they are now, with the 100dp. They should scale correctly. That said, I don't think you need to specify the image size if you're using the full resolution.
Comments to address inaccuracies in my answer are always welcome, even years down the line.

Categories

Resources