Android has a dedicated XML namespace intended for tools to be able to record information in XML file.
The namespace URI is :
http://schemas.android.com/tools and is usually bound to the
Designtime Layout Attributes
These attributes are used when the layout is rendered in Android Studio, but have no impact on the runtime.
In general you can use any Android framework attribute, just using the
tools: namespace rather than the
android: namespace for layout preview.
You can add both the
android: namespace attribute (which is used at runtime) and the matching
tools: attribute (which overrides the runtime attribute in the layout preview only).
Just define the tools namespace as described in the remarks section.
For example the
visibility attribute to unset a view for preview:
context attribute to associate the layout with activity or fragment
showIn attribute to see and included layout preview in another layout