Android Data Binding Library vs Kotlin Android Extensions

后端 未结 3 1601
故里飘歌
故里飘歌 2021-01-31 14:37

I\'m reading about how the MVVM architecture works and how to use Android Data Binding Library help.

In a very general way I understand that Android Data Binding creates

3条回答
  •  时光取名叫无心
    2021-01-31 15:00

    Both, Kotlin Android Extensions and Android Data Binding Library help to eliminate the use of findViewById.

    But there are also more things that these do, that can complement one another. To elaborate, with the Android Data Binding library, you can 'set' models in your xml files, which can then directly be leveraged to set values for the views in the layout. See how a tag can be used with the data binding library.

    Kotlin android extensions does not provide for this. At the same time, Kotlin android extensions provides for some amazing features like @parcelize annotation to make classes parcelable with almost no boilerplate code, etc.

    To conclude, while they both eliminate the use of findViewById, they have their own features too which can complement one another well.

提交回复
热议问题