Can I add views in a layout that are only visible in the design preview?

Viewed 125

I have a layout containing an empty LinearLayout. I fill the LinearLayout with child views dynamically at runtime. Is there any way in which I could preview the layout in Android studio as if those child views were already in the layout XML?

Basically as you can use tools namespace to show a differen preview (tools:text="blabla") I would need something where the entire view would be under "tools" namespace so it would not be inside the app.

The idea I got was to add a view in XML, make it android:visibility="gone" and tools:visibility="visible" but I'm not sure is this a good approach? I wouldn't want to suddenly have double the rendering inside the app when it runs.

0 Answers
Related