Best practices: Layouts on Android (Programmatic vs XML) -
this question has been bugging me time. i've developed couple of apps on android platform , somehow find myself resorting java code in order construct layouts. in professional development environment, acceptable? or should xml files go-to approach? find xml more tedious approach , often, these layouts don't same on devices. don't it. professional viewpoint, has been able develop apps complex views purely using xml files? question killing me because google recommends using xml ui never looks same on devices unless done programmatically. or doing wrong?
note i'm referring android 2.2 , 2.3, majority of users use.
i use xml layouts on pretty every fragment , activity of every app write. see need create views dynamically, tho configuration of listviews, showing/hiding views, etc needs doing in code. me advantages of xml are:
- ability use layout editors (eclipse)
- easier preview layouts
- possible benefit auto-localisation of layouts
- easily maintain different parallel layouts difference devices (screens)
- can sense of layout looking @ (easier code)
- easy break layouts down pieces (fragments, includes, etc) remove duplication
- keeps separation between visual design, , functionality behind it
i can't think of reasons put layouts code - sounds hell.
i expect reason layouts don't same because xml not defining layouts correctly. bear in mind android tools convert xml layouts code, there's no inherent problem using xml layouts versus dynamic - both end code.
Comments
Post a Comment