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.
Related
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
I need to set an image inside the square box under the hanger, what is the best technique to set the new image over this background to exactly fit inside the box in case of small or large screen devices.
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 can I make custom ImageViews in Android like in the picture which all have non-rectangular shapes? I want to be able to load images into these ImageViews and have the images clipped accordingly so that each image stays in its specified area (1,2,3 4). I would preferrably like to specify the shapes of the ImageViews in the layout if that is at all possible.
I also want touches to be recognized only in the exact areas where the ImageViews are.
If not, is there a way to do it with a canvas where I define these different areas and then clip the images loaded into them programatically?
I'm having a problem with positioning images,I need to position a lot images over another larger background image.
An image Like this
I have tried Absolute but it does not keep the position of the image say I wanted to put a clip art image of a board pin over the background image and need it pointing at a sun and when it's clicked I get a popup dialog,
but then when I change the size of the emulator screen the clip art image is not at the same position I wanted it on the background image.
I first tried just putting the clip art on it with a image editor and used onTouch Listener but that didn't work out when I changed the size of the screen with the x and y coordinates. And tried Absolute Layout and that doesn seem to keep the position.
any ideas would help me big time thanks
AbsoluteLayout is deprecated, so it's probably best to use relative layout alongside with dp.
You could use relative layout so you can use layout_below="#id/view1", android:layout_toRightOf="#id/view2", and android:layout_toLeftOf="#id/view3". You can also use android:layout_marginLeft="10dip", android:layout_marginRight="10dip", android:layout_marginTop="10dip", and android:layout_marginBottom="10dip" to move the views left/right and up/down relative to their current positions. There is also ALIGN_PARENT_LEFT, ALIGN_PARENT_RIGHT, ALIGN_PARENT_TOP, and ALIGN_PARENT_BOTTOM. Click here for more properties.
You can manually calculate visible width and height of the image by using its drawable's getIntrinsicHeight() and getIntrinsicWidth() and then set Image's scaleType to FIT_XY (this saves image's ratio, and also makes its size correct, while FIT_CENTER does not).