What is the easiest way to create a form layout like (say) this one:
.-----------------------------------------------.
| First Field [ (EditText) ] |
| Some Other field [ (EditText) ] |
| A Third Field [ (EditText) ] |
.-----------------------------------------------.
I’m a little rusty with my Android, and can’t figure out how to get it right =(.
Details:
-
The whole thing is centered in its container.
-
The labels are horizontally right-aligned among themselves, and vertically center-aligned with their respective input boxes (though I couldn’t represent that in the plain-text above)
-
The input boxes are all the same size.
Bonus points if the EditTexts can shrink or grow up to a maximum width, keeping the layout as above 😀 so as to handle orientation changes without ugly oversized inputs.
Try this layout,
You should always consider using TableLayout for this kind of design than the RelativeLayout, so you can add any number of rows easily and also dynamically.
You may need to put the entire table layout inside a linearlayout or a RelativeLayout and make the table layout in the center and adjust the marginsif you wish.
I can modify it if this doesn’t satisfy your requirement.