Android: How to inject a element into another element in XML?

后端 未结 4 635

I would like to know whether there is a way to insert/inject a element defined in an XML file into another element, d

4条回答
  •  醉话见心
    2020-12-14 05:36

    Yes it is possible, I've created this small library that allows you to resolve these placeholders at buildtime, so you won't have to add any Java/Kotlin code to make it work.

    Based on your example, you'd have to set up your string like this:

    Author: ${author}
    

    And then the plugin will take care of creating the following:

    Author: Francesco
    

    More info here: https://github.com/LikeTheSalad/android-string-reference

提交回复
热议问题