I have a fullscreen view which I partially move in and out from the phone screen, let's say to the half of the screen.
To do this I am using MarginLayoutParameters to set the top margin to half of the screen, or to 0 in case I want it to be fully visible.
Everything works perfect but now that I am testing on other phones, which seem to be the ones of low resolution, the view is correctly cut by half but is always aligned to the top.
Trying left and right margins also always aligns it to the left.
Am I missing something that newer phones/ Android OS already does for me?.
This view is inside a FrameLayout.
Thanks in advance.
Well I just used setPadding with the same results I wanted to achieve, but my question still remains.
Related
Image of XML code and Design Differnce
In this there is a space left right of the image in AVD but in preview, space is fully covered for ImangeView
Same in case if TextView
I want the AVD design same as Preview. Is there any solution of the problem please help
You have to set the layout_centerOrizontal in "true" for each graphical component. It will solve the question of horizontal align issue. But, the preview cannot show all the devices, have this in mind. So, you have to predict somehow to achieve better performance for differents functions and diffents devices.
In your case, with your example, you have to make the all components be on the center (i'm guessing that is what you want). You can work with padding too. So in order to fill the space in a better way (not too empty, like the space below the images on the first image), you can use margin and padding settings that can bring a better looking.
so I'm making a really simple app that just shows some buttons and images,
it looks great on the simulator (because I guess that's the resolution I've been working on ...)
but when I try to build it to my phone it looks differently (the buttons are more stretched out and there is allot more background space in between the buttons and the end of the screen,
I guess it's something that's suppose to be simple but how to I make my app "zoom stretch" to the phone content it's going to be on, meaning it will look the same on any phone and if necessary will stretch the image a bit to fit the screen ?
Thx
In your XML, its important to not use specific(dp,px,etc.) sizes for laying buttons/text boxes/etc. out. For example, for a button thats on the page, use a "layout_width" of "match_parent" and add padding (if necessary from there). This will allow your button to stretch properly without having that extra whitespace.
I'm creating a Dialog, setting a content view with two Buttons, and displaying it. Oddly enough, even though I properly centered it vertically and horizontally, on the Droid X extra blank space appears at the top and on the right side.
I discovered the top is reserved for the Dialog title; even when that title is blank, the space is kept empty. The workaround there is easy enough--I set a title.
The right side, however, baffles me. When I test the same app on other devices it works beautifully; the Droid X, however, keeps the right side of the screen empty. When the root layout of my Dialog's layout has a width of match_parent or fill_parent, it does not extend to that empty area. However, if I manually set a fixed large width, it does extend as far as it needs to--no more empty space on the right side. That's hardly an ideal solution though.
Does anyone know how to get around this Droid X layout quirk so Dialogs do not have that empty space on the right side?
After some experimenting, I found that if I change the margin and/or padding sizes, suddenly the Dialog becomes centered! For example: margins of 4dp creates an offset. But making the top, bottom, left, and right margins all larger and different makes the problem go away.
This sort of behavior generally means one of two things: There's a bug in how the layout is drawn, or I have a gross misunderstanding of how these things work. Both seem equally likely.
So my answer is: play with the margin (and padding) numbers. It's possible that you can find something that both works and is aesthetically pleasing.
Sorry, I know this answer sucks. So it goes.
I've got a pretty weird issue and can't find a solution. These two pictures show my problem:
In the first picture you can see, that there is no fading edge. If I move the bottom gallery a little bit further, the upper small gallery switches its position (I implemented this behaviour) and now there is a fading edge on both galleries.
The issue comes from the small gallery. But I don't understand why it is affecting the fading edge of the bigger gallery. The same effect appears on the right sight.
Both galleries are nested in a linear layout, which is nested again in a linear layout. I never touch the values for the fading edge.
Does somebody have an idea how to fix the issue?
It seems the fading is added automatically and disabling through XML doesn't work.
However disabling programatically seems to work:
Gallery carousel = (Gallery)findViewById(R.id.image_carousel);
carousel.setHorizontalFadingEdgeEnabled(false);
I am fairly new to android and am having some problems with a layout. Below is an approximation of what I want the layout to look like. (I would like the list to be below the screen at first so that the user can scroll down to see it.) However my code as it currently stands makes all of the views on the left only take up a quarter the screen instead of half, as depicted, even though I have all widths set to fill_parent.
Also, this layout seems to mess up the coordinate system on my custom view. Normally this wouldn't be much of an issue, but in this case I am using that view to draw a picture and the picture ends up in the wrong place. Does anybody have any idea how to resolve these issues?
Could you show the XML file you are using? This would be helpful. Also, the coordinate system of a View does not change based on the layout.