At the moment I have just targeted my UI graphics for the hdpi resolutions for android and this works flawlessly, the graphics are designed with 3 resolutions in mind with only the background image being altered really. Problem is the plan was to use the same images for hdpi (480x800 and 480x854) and as well as mdpi (320x480). But when I test it for mdpi with the images in both the -hdpi and copied into -mdpi it doesn't scale them down, do I have to resize all the images and have them duplicated for the mdpi screens?
Sorry if this is not very eloquent it is the first time I have done any UI design for android and still don't understand it properly.
Android should correctly use the right image when you use R.drawable and your images are in drawable-hdpi, drawable-mdpi etc. Since that is what I think you've described as what you've done, it hints that maybe you've hardcoded a size? Are you using ImageView and set a size for them? If so, did you do it in Java code or in XML? If in Java code the values would be in pixels, so 50px on mdpi screens will look larger than on hdpi screens. If you used XML did you again set a size with px? If so, you should use dp.
Related
I want to show this image in an Android (Java) app, but the app displays it as. How do I display the first image in an app without getting this blurring effect?
EDIT::
And how can I change the size with no blurring effect?, the imagen will show pixelated. Like this http://i.gyazo.com/18b227adb4c442b09152ca6ebc04c54c.png
To show image with the original size use layout_width="wrap_content" and layout_height="wrap_content". This is considering that your image is smaller than the screen in which it is to be shown. Also if you only provide image in your drawable-hdpi folder then the images in mdpi screen with be scaled by a predefined scale factor(possibly 2). Same case applies for other screen density. To avoid this scaling you can put your images in drawable-nodpi folder.
Note: the images you posted are not properly made(highly pixilated). Try optimizing the resolution and provide multiple resources.
I would like to ask if I'm developing a 4 inch based app device and has a 100x100 px image button, what would be my dynamic images to be placed on the drawables? xhdpi, hdpi, mdpi,ldpi and so on to make it responsive every time it is installed on different devices.
Did you checked out the related best practices for Multiple Screen supports from developer.android.com. It explains nicely how to make layouts fully responsive
Read this article thoroughly and you will get what you want.
I'm trying to understand multi-screen support in android. Yes I read the documentation, but still have few questions.
As I understand i need to create drawables for each density, but what to do with text size?
I want to set title on my activity which will fit any screen (need to big big enough and don't warp the text)
I test in on my Nexus7 (large screen) and it looks good with android:textSize="100dp"'
When i launch it on emulator with 'normal screen' size i get very big text.
So is it right solution to make layouts for each screen size?
'layout'
'layout-large'
'layout-small'
....
and just make android:textSize="70dp" for normal screen and android:textSize="50dp" for small screen?
And another one question how to test all this in more efficient way?
I need to create emulators with? Where to get parameters with which create emulators to get this results?
XLarge screen
ldpi
mdpi
tvdpi
hdpi
xhdpi
Large screen
ldpi
mdpi
tvdpi
hdpi
xhdpi
Medium screen
ldpi
mdpi
tvdpi
hdpi
xhdpi
Small screen
ldpi
mdpi
tvdpi
hdpi
xhdpi
For text size you should use sp units. Docs say:
Scale-independent Pixels - This is like the dp unit, but it is also
scaled by the user's font size preference. It is recommend you use
this unit when specifying font sizes, so they will be adjusted for
both the screen density and the user's preference.
As I understand i need to create drawables for each density, but what to do with text size?
As WebnetMobile indicates, you start by using sp, as this takes the user's choice of font scale into account. However, you may need more than that.
So is it right solution to make layouts for each screen size?
I would recommend using dimension resources, with different definitions for the text size dimension as needed for your different scenarios.
Where possible, though, design your UI to be more flexible about font sizes. Again, if you use sp, the user can change the size of the text on Android 4.0+, to make it bigger or smaller, to help them read the text on their device. Hence, you cannot assume that you are in complete control over the size of the font, and therefore need to design accordingly. This is not significantly different than designing a Web site that takes into account users' adjustments to font size in their browser.
And another one question how to test all this in more efficient way? I need to create emulators with?
You will need emulators or devices for whatever scenarios concern you.
Where to get parameters with which create emulators to get this results?
On the (now-current) R21 versions of the tools, you set the screen size and density in the Device Definitions tab of the AVD Manager, then create AVDs based upon those definitions as needed.
Inorder to test in different screens and density you can create emulators with different combinations. When we create the emulator device we can set the Density (Abstracted LCD density under hardware).
ldpi - 120
mdpi - 160
hdpi - 240
xhdpi - 320
You can set the screen size also while start the emulator
I'm using the Canvas and the SurfaceView. I've explicitly mentioned the coordinates for various objects and fonts on the screen. The app runs perfectly on Samsung Galaxy S Advance but the objects are out of scope on smaller screens such as that of Samsung Galaxy Fit or Pop. How do i make it compatible for all screen sizes and pixel densities.
Using dpis seems out of the question as I'm not using any xml layouts.
Thanks in advance.
I think you should get screen resolution at run time and set pixels according to that.
According to the developer guidelines it is discouraged to do so (work with explicit coordinates). Please refer to the android design guidelines for how to do it better. If you cannot avoid it, you'll need to take into account the screen size and density and compute your coordinates accordingly.
Is there a good method to create HD like graphics for regular 480x800 devices as well as tablets? So far I can create HD like graphics for only 480x800 devices. And since i'm using OpenGL i place all of my graphics in the assets folder. My images are in the 480x800 format. I have thought of multiple ways and they are listed below.
I tried using 480x800 graphics and using OpenGL to stretch it to a tablet with GL_LINEAR. As expected, the graphics were great on the 480x800 devices and average if not poor on the tablet.
I have not tried this but I believe this to be a good method (need clarification). Using seamless textures and creating my background from those. (problem with this is that my character would become non-HD like).
(Soon to be tried) Using the res folder instead of the assets folder. Seperating tablet graphics and phone graphics. However, i have not come up with a good method to place these graphics in identical places with OpenGL. [need clarification on this :)]
What are some of your good methods to create HD games for both 480x800, 480x854 and tablets?
The answer is the one you probably expected - for the best results you should create images of different sizes and use the most appropriate set.