Does Android support layout inheritance (similar to Django templates)?

后端 未结 2 1269
故里飘歌
故里飘歌 2021-02-05 12:31

I may be misunderstanding how and work, but according to Simple example of and usage in And

2条回答
  •  有刺的猬
    2021-02-05 12:53

    I've solved this by adding ViewStub entries into the layout xml of the parent, and - depending on the type of subclass - inflating the correct stub.

    http://developer.android.com/reference/android/view/ViewStub.html

    ViewStub is sort of lazy loading a view, so if you never call inflate() on it or never make it visible it won't be added to the layout hierarchy.

提交回复
热议问题