Dynamic vs XML layout in Android?

后端 未结 7 608
不思量自难忘°
不思量自难忘° 2020-12-06 00:57

I\'m new to Android development and have started creating my own UI. I see that you can either create it dynamically something like this (Dynamic Layouts):

@         


        
7条回答
  •  时光说笑
    2020-12-06 01:31

    I would recommend using xml layouts for most parts of your projects. You can put the layouts in different folders such as:

    layout-land -> for landscape

    layout-port -> for portrait

    layout-v15 -> for android version >= 15

    layout-sw600dp -> for screens with a certain width

    Using these resource classifiers you can quickly have a wide variety in your layouts to support the wide range of android devices, without have to code a lot extra.

    In my oppinion, that's the biggest advantage of using xml resources vs creating all layouts dynamically. For more info see this link about resources

提交回复
热议问题