Android Layout Fill_Parent Problem - android

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.

Related

Difference between design in preview and android virtual device

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.

Android Preview vs Emulator Layout Size

Folks,
I cant design my android screens and see it on my emulator somehow the resolution, zoom (whatever) in the emulator is big and my layout is messed up.
The whole layout is inside a FrameLayout, the paragraph text in the emulator pic is inside a RelativeLayout, which is set to GONE after users upload rating, then LinearLayout shows up with the overall rating bar in the some place where the RelativeLayout was.
My question is why is this happening since in the preview it seems perfect and on the emulator it seems all messed.
Please see the screenshots:
Android Studio Preview:
Genymotion Emulator
It is really hard to determine what exactly is wrong without seeing your xml markup.
Possible Reasons
You gave your layouts some sort of fixed size, and therefore it appears to be fine on your markup, but whatever you are emulating on Genymotion is using a different ratio.
When you do a View.GONE, you say you are replacing a RelativeLayout with a LinearLayout. Well, do you make sure that the layout that is replaced is layoutAbove whatever that frame layout below it is?
Some layout just has some attribute, like an alignment issue, that is causing this.
Trace your steps backwards, removing one thing at a time. Get it to work with that view gone first, then add it and manipulate it after.

The right layout for a curved set of buttons?

I'm working on creating a menu screen, its fairly boring set of buttons so I wanted to add a curve to their layout to make it a bit more interesting. Like this:
I've just added the curved line to give an idea of what I'm doing - it won't actually have a line when done.
My question is what is the best way to go about doing this. I have tried using a linear layout and then applying a left padding to push them increasingly away from the edge. The problem here is that this depends on the screen size. On a small screen it displays fine and on a larger screen it does not. The second problem I have it that I'd like the entire curve to be centralized in the screen. Should I use a linear layout nested inside another?
If anyone has any ideas or sample layout xml as the best way to achieve this that'd be great.
Take a look on this widget, they doing someting like this
Maybe a relative layout so you can the position of each button relative to the one that comes below it?

Android Layout On Top of an Image

I am struggling with a Layout Problem on Android. This is very simple to do on the iPhone, but with the various screen sizes and the Layout classes available. I am having a hard time doing this.
One thing that I have noticed is that setting backgrounds on objects in the xml really messes up the layout on the device. I generally have to put in a FrameLayout and an ImageView to get a background.
So Am trying to get to this. http://www.calidadsystems.com/images/AndroidListItem.png (Sorry I don't have enough pts to post the image)
his is a status view and is an item in a List View. There are 8 TextViews that need to be set. Each of the 222 fields will change. The current background has the colors in there at specific locations and I am trying to line up the Labels and TextViews to get the picture below. I built this one with AbsoluteLayout which is deprecated, but it also does not work very well on the device.
I have constantly struggled with the layouts on Android. Does someone have some good sample code that could do this?
You're probably going to want to use a RelativeLayout. You can use the android:layout_alignTop="id" attribute to make the rows be in line correctly. And android:layout_alignLeft="id" for the columns. Other than that its just a matter of playing with the android:layout_marginLeft="XXdip" attribute to get the space between them how you want it. Check out this page for an overview and examples of all of the Layout types. Here is some more sample RelativeLayout code. And one more page with another example. RelativeLayout is a bit tricky to get used to but once you've used it a few times its pretty easy to understand and get the Layout that you want. The benefit of it is that your UIs look nice on several different screen sizes when you define them this way.
Why not just composed the layout in a table layout and set the table layout's background to a custom made graphic you make? This should work well with you. Specifically the design of your design would be like 4 columns with x rows. Then using the strechcolumn property, you should be able to accomplish what you are trying to do!
If you scale the graphic properly, then you shouldn't have this problem overall.

Android View Design Issues

I've been playing about with the layout of a view with Android (lets say within the MainActivity) and I'm looking to create this sort of layout using 3 ImageView's (where each block represents an image):
This is rather easy to pull of using LinearLayout's but only if you specify the exact size and position of each ImageView. This then obviously causes problems when looking at different screen sizes.
Using AbsoluteLayout looked like it was going to work at first, but I've read that it's deprecated and it still causes problems with different screen sizes.
Then there is RelativeLayout, which I've tried using with DroidDraw, but it doesn't seem to get me very far when I implement it :(
So, does anyone have an ideas of how to achieve this?
EDIT: I've got close to doing this using dp instead of px but this still gets screwed up when using larger resolution devices! :(
Thanks
Romain Guy does something very similar using RelativeLayout. Android Layout Tricks #1
One solution is that you could use a TableLayout with 2 columns, and then in the second column embed a second TableLayout.
DroidDraw doesn't always show exactly how it will work when it runs 100% of the time I've noticed.
You can do this with a horizontal LinearLayout: add the green first, then add a vertical liner layout for the blue and orange and give each an appropriate weight (like 50 and 50).
You can still use LinearLayout but make the width/height in dip units. Thatvway it should look the same on any supported screen size. Alternativly, you could use the weight attribute instead which is probably a better idea for this case.

Categories

Resources