Android Layout Manager scaling images - android

I am using the Linear Layout Manager and I am trying to use the image width and height (wrapContent) automatically within the application. However, all of the images are appearing larger than what they should be. I think I know why: If I put an image that is 320X480 on the screen, on my device that has a pixel resolution of 480X800, it fills up the entire screen. This results in all of my images being too big for this screen, as I am building my images for a screen size that is 480X800.
Does anyone know how to fix this?

u can use absolute layout!
and can set the width and heigth of the image as u want!
go to the layout xml page and then change it to Absolute layout.
then you can easily change the the width ..
right click -> property
set the height and wigth as u like... Eg:"120dip"
it will solve your issue..
if not let me know will provide you another alternative

Related

Android: Stretch Widescreen Image to fill the whole screen

I have a Widescreen Image that i want to put into a horizontal scroll view, with it ftting the whole screen vertically(and letting me scroll horizontally) but it simply stays at half height and won't let me scale it higher (layout_height is set to "fill_parent").
I already thought about using the image in different source resolutions but i think i cannot cover all possible resolutions so that is not really an option i guess.
I also want to put buttons on specific locations onto that image and want them to move with the image if that is important.

How to have images go to the next line if they dont fit

I am using Linear layout with horizontal orientation to put images beside each other. However, is there way that the images can automatically go to the next line incase they dont fit due to screen size?
I just dont want small screen (or small densities) to truncate my images
Thank you
Use RelativeLayout and reorder images via code according to image sizes and space.
OR
Extend GridLayout and make your own implementation of it.
This is not possible in LinearLayout as it is.

What width of image required to fulfill width of android screen

On an android xml file or graphical layout
I want to create an imageview that hold an image.
My question here is what the width of the image in pixels required to fulfill the Android Mobile width.
Since different Android devices have different screen sizes, you won't be able to set an absolute width to fill the screen. You can use android:layout_width="match_parent" as the width for the ImageView and it will resize itself to fit the parent view it's added to.
just write that in xml under ImageView tag
android:layout_width="fill_parent"
thats it
The device width of each android device differs. If you would like to fulfill the image on a device, then it might be streched or truncated on four sides based on the Image width. It would be a nice idea make hte image center, so it looks on all the devices or you might need different sizes of the same image depends on the device widht and height

Button height dynamic

I want to create my button height using drawable xml file and it should also resize dynamically with my layout, so that it can support any Android device.
Currently I am using RelativeLayout with match_parent height. I want to put a set of 3X4 buttons in this layout and should automatically resize with the device height.
I am not able to resize it properly when I use dp values. If I resize the button for large res device, it is not working fine for 240X320 res device.
Yes, you should be able to do what you want with the Android layout classes. You aren't completely clear, but it sounds like GridLayout is what you want.
The default Android UI element should deal well with being sized dynamically; if you have a custom drawable asset, you'll want to make an appropriate 9-patch image at each of the common display densities (so that it not only resizes correctly, but looks good on a range of devices).
I have recently been thinking about this very topic, and I think I can help you. If I understand you correctly, you would like to have your application dynamically resize your buttons depending on the screen size. In order to do that you can use binding and a converter. If you bind your button's height (and width if you prefer) to the page's height (and width) you can use a converter to convert the value to a percentage of the screen size. If you like, I can provide you with some sample code.
You can get the size of the display Display display = getWindowManager().getDefaultDisplay(); and set the sizes dinamically.
Or, you can make various sizes of your images.

Fit Image on an android screen

I'm having a trouble here on hot to make my background image fit on a high resolution screen. It works just fine in a 4" screen but image won't stretch out when I deployed it on a larger screen. I tried to search for an answer but nothing helps as of now. well this might be a problem with my xml code but I'm not really sure. My design works with 1 table layout and 2 table rows for the 2 objects. And on the LinearLayout I set my background image.
For further understanding I made a sample on how it looks like when deployed.
There you go. It works fine on my phone while It doesn't occupy the whole space in Galaxy tab. Also as much as possible I would like to make my background image in smaller size around 320x480 pixel is size and just stretch it out.
Set your layout height and width to FILL_PARENT?
Its clear that you did not set Layout_height and Layout_width to fill_parent .
also for better rending put images in all three drawable folders drawable-mdpi, drawable-ldpi,drawable-hdpi .
also make your background image as 9patch will be nice for resizing a backgrond .
Well there are so many reasons I could point out for this problem of yours.
1)First thing the first screen shows a mobile screen and the next one shows a tab avd.
2)The image what u have should be in size to fit a mobile of particular resolutions only.
So your only hope is to get a image with resolution that fits the tab.
Or to change the wrap content to fill parent for your width and height.

Categories

Resources