julianomoraes / componentizationArch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Preview in AS

realsoc opened this issue · comments

Hello Juliano
I was wondering if you found some way to get a layout preview as a whole.
As we adding view and constraints programmatically, I am not seeing a good way to do that in AS. So I either develop blindly, or duplicate the code to have a layout with the same constraints as the Activity and get my preview this way.
Any thoughts ?

We've been using XMLs for individual components, using this approach you can have the screen (parent) main XML including all the individual components and visualize it in AS.

But as the views are added programmatically, nothing lives in the parent main xml, right ?
I did create a fake main parent including every child layout, and that's how I get a preview. But any time I change a kotlin constraint I have to do the same change in this fake xml to update the preview (or vice versa).
Don't you have to apply the changes twice ?

If you inflate the parent with includes you can pass the parent rootview to components and just findViewById of whatever you have inside your includes.

Woow this is way better !!
I was adding the views programmatically, having hundreds of lines to set the constraints and without any preview.
Thanks you so much for the tip and for this futuristic architecture.
Can't wait to see your talk at the Droidcon