How do i position a button in xml. Im using Eclipse with android sdk, i just used margins to put the buttons in positions. But how can i do it through the postion function?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Placing a button on the screen using xml is going to very depending on what you use for your root view group.
There isn’t a position function like what you are probably thinking where you would set the X and Y position of the button and for good reason. Because of the hardware fragmentation of android devices it would be difficult to write portable UI if you were relying on hardcoded X and Y coords (regardless of portrait vs landscape).
As an example if i wanted to put a button in the bottom right of the screen and I had a relative layout:
This will put a button on the button right of the screen regardless of screen pixel density/resolution or even landscape VS portrait