Reputation: 3080
I've been looking on best practices for designing Android UI's. While there is a lot of information out there around programming the actual code, there are very few tutorials on doing advanced xml design for Android. If you know of any tutorials, please link them here.
I currently find myself using TableLayout with decent results to achieve some more complex UI layouts. I like that I don't need to supply TableLayout with any fixed width or height values, however, I have had to use strange work-arounds like an empty between two buttons to create a fake 3rd column, stuff like that.
I know there must be a better way than using tables and fake RelativeLayouts for spacers, can someone please explain how RelativeLayouts work on different devices. For instance, if you have a LDPI device, will it display your UI differently as it has less width and height pixels? What if you used 480px (hdpi standard width) as a width property and your UI was displayed on a LDPI device? Would it overflow the screen?
My tables and spacers trick works pretty good, it's almost good enough to stick with it, however, I want to design my UI properly so it works with the most devices possible! Please point me in the right direction, cheers!
Upvotes: 1
Views: 1761
Reputation: 6940
RelativeLayout is a great way to go. If you set Views' distances and sizes with dp, those distances in dp will be treated as pixels on an MDPI screen, and they will be scaled so your layouts fill the space equally on LDPI and HDPI screens. The Android Developers tutorial on views has a good section on RelativeLayouts.
Upvotes: 2