I have a XML that defines a screen layout(couple of edittext,textview boxes). I have done setContentView(Resid) and am displaying the view on the screen. Now, I want to add a couple of buttons at the bottom of the screen and "preferably" at the center.
I created buttons in code and when i added them on the screen. Both the buttons got added over one another and at the top left of the screen. I figure this could be a layout problem. Can anyone help?
Please share links that shows how to draw a view ( by mixing XML layouting and view created in code) if you have..
You're probably not adding them to the right parent, or perhaps you're not setting the LayoutParams correctly. See section 8.3, Bird's-Eye View for an example, or here's a direct link to the code:
I think you are using Relative layout. Specify the parameters for alignment of the buttons. For example your want the button below the text field, then you have attributes like layout_alignBelow to which you can give the reference of the text field. (this is wrt xml) Refer the below link for the attributes.