Multiple drawables background images to fit the screen resolutions - java

Alright, so I have an image that it's resolution is: 1054X1054.
I want to set that image so it fits exactly the screen size of the android devices. (I'll cut the image in some editor as nessacary).
So my question is: How can I know what resolution my image should be so it will cover the device background without needing to resize the image.(For the mdpi,hdpi,ldpi)
I'm asking that question because I keep missunderstanding how the "multiple screen resolutions" really work..

you can design your image to re-size with different screen sizes, you'll discover that each design requires a minimum amount of space. So, each generalized screen size above has an associated minimum resolution that's defined by the system.
android os count sizes in "dp" units—the same units you should use when defining your layouts—which allows the system to avoid worrying about changes in screen density.
xlarge screens image sizes are at least 960dp x 720dp
large screens image sizes are at least 640dp x 480dp
normal screens image sizes are at least 470dp x 320dp
small screens image sizes are at least 426dp x 320dp

Related

How can I support multiple screen sizes in moblie game deveopment

For this question, I am specifically referring to android.
I want to learn how to make a game and ensure that it will work on devices with different screen sizes. I test the apps on my phone, which has a huge screen. But if a user downloads it and has a smaller screen size, how will it affect the game? I'm using libGDX.
Usually you set the dimension of a "virtual screen" that you will consider the real screen inside the game will be rendered.
This way you can easily project the dimensions of your actors ecc.
Then you use a ViewPort that scale your "virtual screen" to fill the real screen (that has its own real dimension in pixels).
Obviously there's a problem about the aspect ration.
Typically it's better to choose the dimensions of the "virtual screen" properly; for example if you choose a virtual ratio of 800x480 the game won't be look stretched on devices that has the same aspect ratio of the screen.
This in not the only solution...maybe it's better if you take a look here [https://github.com/libgdx/libgdx/wiki/Scene2d][1].
Luca

LIBGDX drawables on devices with different densities/resolutions

I'm new to LIBGDX game development, and I have faced my first problem. I've created 9.patch drawables (buttons) using texture packer. This drawables can be used on low density and also extra high density screens and quality is the same.
If I run my project with that drawable on desktop project the image shown is okay and perfect size. If I run project on low density android device, drawable becomes huge (almost half of the screen). And also If I run project on extra high density android device the button becomes really small.
So my question is, how to handle drawables in LIBGDX, so the ratio (screen:image size), stays the same no matter resolution/density..?
If your button is a text button. Change the font of your text.
If you are using image button, this might help you
It kind of depends on what you're drawing...If you are just drawing an image, I've found it easier to specify a float width and height in the last 2 parameters of the draw method. If you are using a camera with a fixed viewport size, you can simply use a fixed percentage of your camera viewport so it will always be the same dimensions and draw like this:
batch.draw(drawable,x,y,screenwidth * 0.5f,screenheight*0.5f);
However, if you are using buttons or some other widget inside of a table, you should specify the cell size and it should automatically be resized based on the size of the table cell. Something like:
myTable.add(myWidget).width(300).height(200);
Post up exactly what it is that you need to draw if you get a chance and it will be easier to figure out what needs to happen.

How to detect the zoom factor of an image

I read the related question on this topic here: How to detect subjective image quality
I would like to detect whether the uploaded image by the user could be zoomed in at high % (say, 500%) and still be or good image quality. I understand that "good image quality" is subjective, but for my purpose I would say it means "whether the image is pixelated?". I'm trying to find ways of how to do that?
Should I calculate the size of the uploaded image? Higher the size, more zoomed in it can be?
Should I calculate the total pixel count of the image?
Should I read the metatags of the uploaded image?
Combination of multiple things?
Are there solutions/libraries out there that determine the bad pixelation of an image?
Use the horizontal and vertical pixel count.
As long as the image has more pixels than you're displaying, you can zoom. Once you have more display pixels than image pixels, you have to interpolate the pixels. The higher the interpolation, the blurrier the picture.
Say you have a 4000 x 3000 pixel picture, and you're displaying 640 x 480 pixels.
You can zoom up to 625% horizontally (4000 / 640) and 625% vertically (3000 / 480). The smaller zoom number would be 625%. Rounding to an even zoom number, this picture could be zoomed up to 600% without pixelation.
Now, you could zoom even higher than 600%, if you're willing to interpolate the pixels. How high can you zoom? That would depend on what you consider acceptable interpolation.
My guess would be 25% higher. For this example picture, you could go to 800% before the picture got too blurry.
If you want to be on the safe side, keep it below the calculated zoom size. If not, go as high as you wish and let the user determine how high is too high.

TextView dp does not scale with screen size

I am attempting to create a textView that will take up a large portion of the top center part of the screen. Ideally, setting the text size in dp would allow the textView to remain the correct relative size (taking up about 70% of the width of the screen, and maybe 20% of the top). It looks correct in the layout editor, and in the emulator at HVGA resolution. However, when I test it at higher resolutions (on my tablet, or emulating a 720p display) the text takes up a very small portion of the top center part of the screen. (maybe 30% width instead of 70%, and it doesn't seem any larger vertically).
Is there a way to scale text to correctly increase relative size with resolution?
Set the layout_width as fill_parent, which will make it spread across the screen for all devices.
Add some padding on left right and top which seems suitable.
The padding might seem different for different screens but still this might be a better solution.
set
android:layout_width="match_parent"
edit:
check this out
Auto Scale TextView Text to Fit within Bounds

Android Different screen

Welcome.
I need to prepare UI for different screen sizes. I make layouts
layout-small
layout-normal
layout-large
layout-XLARGE
For this I-small drawable, drawable-normal, drawable-large, drawable-XLARGE.
But where to get the screen size from small to XLARGE. I mean the size of
For example, 320 x 480 Where to get the dimensions for each screen? To prepare the graphics?
if you want to do in code you can use Display class of android and use method getRectSize and getSize for the same. Please See API here
If you want to see the differences between screen sizes you can look at this Supporting Multiple Screens
first of all you have to read this at least. As bit of advice, you can start with the graphics for the mdpi device. For the mdpi devices 1 pixel is equivalent to 1 dpi. Then you can make the same graphic for the hdpi just multiply the pixel of the mdpi image * 1.5, and for the ldpi just multiply the pixel of the mdpi image * 0.75..

Categories