20

I have a ViewStub like this -

<android.support.constraint.ConstraintLayout>
    <ViewStub
        android:id="@+id/photos"
        android:layout="@layout/add_photos"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:visibility="visible"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/details"
        tools:visibility="visible" />
 ...
</android.support.constraint.ConstraintLayout>

But the ViewStub is not rendered in the layout preview and design tabs. Using <include/> works though.

I am using Android Studio 3.0 Beta 6.

Is there a way to render preview when using ViewStub?

EDIT:

Looks like there is a feature request in google issue tracker https://issuetracker.google.com/issues/37090997. But no one has looked into it till now. I will still keep the question open if anyone has any workarounds.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62

1 Answers1

18

Add this to the ViewStub:

tools:visibility="visible" 

and declare xmlns:tools="http://schemas.android.com/tools" in your layout.

Lucas
  • 1,224
  • 1
  • 14
  • 21