vendredi 3 décembre 2021

How to define components that could be shown at different times in the same place of the layout

I have a ViewPager and the majority of the pages have exactly the same structure, and only a couple have a very minor portion different.
I am using the same ConstraintLayout for all the pages and the structure is as follows:
enter image description here
Basically the middle area with the arrow is the part that differs. Either custom component1 is shown or custom component 2.
Currently what I do is define both in the xml layout having one as visible and in the code, I just hide/show the proper one depending on the case.
But I was wondering if there is some alternative design or way to define this at the xml level?

Aucun commentaire:

Enregistrer un commentaire