I have a landscape layout that features a vertical LinearLayout of buttons on the left side of the screen and a user-defined picture on the right of the screen. The design I'm working from calls for a double-stroke border around it, which I implemented by creating a rectangular shape background with the border being the outer color and the background of the shape being the inner color. I then just put some padding around the picture, and you get the double-stroke border. The problem is expanding the picture to fill the space in the layout. I don't know the dimensions of the picture, since it is user defined, and I'd like it to expand to exactly fill either dimension while preserving the aspect ratio. Setting fill_parent for both width and height does that, but it also expands the background all the way to completely fill the cell, resulting in a sort of letter boxing effect. Is there any way, short of just adjusting the size of the view after layout, of getting this to only expand the view as much as necessary?
I never got this to work properly, and just ended up adjusting my layout to a different arrangement.
Related
I want to achieve the following:
a picture, as a background, which resize according to the screen size
I want to put button on top of this picture, while maintaining a proportional position to the picture width and height.
See the example:
The background is an image with the fill_parent settings for width/height.The yellow squares are buttons on top of this picture.
So, how can I keep the button on the exact same position on top of the picture with different screen size, using relative layout (or others layout)
The solution was to use the "Percent Support Library" as stated by #subhash
I need to create a layout in Android like the image below:
The red rectange is the viewport. it should be possible to zoom in and pan until the borders of the image that contains the 4 imageviews.
I've tried putting the images in a gridview, that didn't really work
After that i tried putting them in a tablelayout, but the images have to keep aspect ratio.
so each row in the tablelayout had the correct width but the height was only half the rowview.
So when i pan it's possible to see the white edges from the rowview that was not filled completely
What would be the best way to achieve this layout?
I have some problems resizing ImageViews and ImageButtons.
Let's say that I have a Layout that has a rectangular shape (I don't want to know if it is a horizontal or vertical rectangle) and a ImageButton that contains a transparent background and as ImageResource a square image.
I want to keep the button square, so I use setScaleType(ScaleType.FIT_CENTER) to stretch the button. It works well.
The problems come when the button needs to be REDUCED to fit the rectangular layout, instead of stretched: in that case, the image is reduced correctly, but the space reserved in the layout is the one that would be reserved by the image if I hade made it crop.
This is what I think that happens:
the image is put in the layout
the space in the layout is reserved
AFTER THIS the image is resized
if the space asked is increased, the layout is enlarged, otherwise nothing is done
as a consequence in the layout the image results rounded by A LOT of empty space if the image needed to be reduced.
The classical problem is: I have a layout that should contain one row with - say - six square buttons. IF the button size is larger than the height of the Horizontal LinearLayout, the buttons end to be distantiated with a lot of empty space, instead of touching them.
I tried using fixed sizes for the images, to force them resize before putting them in the layout, but this is not a solution for me. First of all I want it to be dynamic (ie: the layout could change size during the app lifetime and the images should follow that). Second of all, when I put the image into the layout it can easily happen that the layout is not set yet and its size returns zero.
Can anyone help me?
Thank you.
Just add the attribute
android:adjustViewBounds="true"
to your image view element in your layout. You can have a look to the post Unwanted padding around an ImageView
I have a problem with a specific layout in Android.
What I want to achieve is approximately this:
http://imgur.com/xiN0u
The green area should always be visible at the bottom of the screen (size can change, but only marginally)
The red area should fill the rest of the screen on top.
The cyan area (inside the red layout) is a ScrollView and can change size and should not grow bigger than the space available
What happens is this: when the list expands, depending on the layout (i have tried linear, relative, mix of those,...), either the red or green area is overlapped with the other and is not accessible any more:
http://imgur.com/b7leA
I have tried this for a day now and whatever I do, some part of the layout is always overlapped. Is there a way to tell a ScrollView to only expand to a certain height? I know maxHeight doesn't exist. I highly appreciate every input as this is driving me crazy now! Is this possible at all with Android?
I'm trying to create a layout with multiple buttons, But all buttons was not displayed on Screen, So i used scroll view but now i have one problem because of background image (which is of high resolution). Now i'm getting very large empty space under after buttons. Please suggest a solution how can i fix scrollView hight so that it doesn't show the space under buttons.
like This :Area with white background is Moblie visible screen and off white area is background image.
The best solution would be to use an appropriately sized image. If you only want to display part of the image, but the image is a high resolution image, then you are wasting resources by loading the entire image.
You could enclose the ScrollView within another View, and set the background of your parent view to be whatever background you desire. Set the height of both views correctly and you should achieve your desired result.
The hierarchy would be
View (with background image)
ScrollView with buttons