Does Android XML Layout's 'include' Tag Really Work?

前端 未结 3 1632
臣服心动
臣服心动 2020-12-04 09:16

I am unable to override attributes when using in my Android layout files. When I searched for bugs, I found Declined Issue 2863:

\"include tag is bro

3条回答
  •  清歌不尽
    2020-12-04 09:50

    I submitted an enhancement request to allow all included attributes to be overridden:

    Suppose I have two identical layouts other than the values of a TextView field. Presently, I either have modify the layout at runtime or duplicate the XML.

    For example to pass two parameters with values "hello" and "world" to layout1:

    layout1a.xml:

    An alternate implementation would break encapsulation and would allow the include statement to override values like:

    layout1b.xml:

提交回复
热议问题