Search code examples
androidandroid-layoutadtandroid-xmlgraphical-layout-editor

Are there debug XML tags for the ADT layout editor? E.g. to make collapsed views visible in preview


I want to have collapsed views (with Visibility=GONE) to be visible while using the layout editor of ADT.

Are there any debug xml tags to show the layout in preview differently than in the running app? I remember seeing them on Microsoft XAML.

I intented to use this workaround, however the app crashes then while inflating the layout: I set up a string resource with the value of either "gone" or "visible". The visibility attribute of all collapsed views refer to this string resource. Now I have only one place to set the visibility of all that layouts.


Solution

  • You could use isInEditMode() in a custom layout class, to see if the layout is being rendered as a preview, in an IDE.

    However a much easier solution would be to keep it visible and just programmatically set it to GONE, once the layout is done inflating:

    findViewById(R.id.container).setVisibility(View.GONE);