How do I set tools on phone screen according to android phone height and width?
I am new to Android layout development and have been tasked with designing and developing an application.
I have created the absolute layout but it is giving me different ways to output in differ开发者_开发技巧ent android phone versions. For example, when I set the EditText
, Button
, TextView
etc. in my phone, I get a perfect view but when it runs on the client’s phone it looks very bad.
It is very important for me to set the same view for different phones. I would appreciate if someone can provide code examples for controls in absolute layout so I can get the same output on all phones and set height and width so that they are same in phones with different resolutions.
Thanks in advance.
If you're using AbsoluteLayout
you're already doing it wrong. :) It's deprecated precisely because it makes working with multiple screen sizes unnecessarily difficult, just as you've observed.
See RelativeLayout
for a better approach. RelativeLayout
lets you specify your layout in terms of rules, e.g. "Place view A along the top of the screen and stretch it to fill the full screen width. Place view B along the left edge below view A and let it be as tall as it needs to be to fit its content."
You should also reference the link posted in yogsma's answer for more general advice.
精彩评论