My app works perfectly in resolution 480x800. If I keep the 480x800 resolution but change the screen size to for example 2.7 inches, 3.7 inches or 5.4 inches it still is perfect. But when I change the resolution to for example 640x1066 all the ImageButtons is too small and in the wrong place in all screen sizes...
This page shows you how to support different screen sizes with the following techniques:
Use view dimensions that allow the layout to resize
Create alternative UI layouts according to the screen configuration
Provide bitmaps that can stretch with the views
Visit this link https://developer.android.com/training/multiscreen/screensizes
Related
Currently in the process of assigning images to the main menu to make it more aesthetic, however when assigning images to buttons how do we know what the correct resolution , aspect ratio or dpi is
For the background I know we can use 9 patch images, or provide the various dpi sizes. For an image button, what would be considered the best bet
Thank you
Covert your images accordingly into hpdi, xhdpi, xxhdpi, xxxhdpi using image resizer and put them in all drawable folders. and for image buttons to set icons use src attribute so icons will be set properly in center.
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.
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
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
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..