I don't want set visibility programmatically and I make it in xml files, but when I set visibility property to GONE view hides from preview screen. Sometimes I need to correct some field in gone views and I must change visibility to VISIBLE, make changes and change visibility back. It's annoying.
How to make view with visibility GONE visible ONLY in Android Studio preview.
To turn it on manually, navigate to File > Settings > Editor > Live Edit (Android Studio > Preferences > Editor > Live Edit on a Mac).
Open an existing layout in Android Studio, and click the Design button in the top-right corner of the editor window. In the Component Tree, right-click the layout, and then click Convert your-layout-type to ConstraintLayout.
There is indeed a simple way to do that:
Define the tools
attribute in your main Layout:
xmlns:tools="http://schemas.android.com/tools"
Use it to make your element visible, like you normally would:
tools:visibility="visible"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With