title: Android compound view in preview not showing height or contents
body: <p>I'm creating a custom compound view which extends <code>LinearLayout</code> (also tried <code>ConstraintLayout</code>) which contains 2 child views. When the app is running the view lays out correctly, however in the preview window it shows as 0 height when I use <code>wrap_content</code>. When the view was extending <code>ConstraintLayout</code> it was rendering as <code>match_parent</code> when the view was set to <code>wrap_content</code>.</p>
  <p>If I override <code>onMeasure</code> and force a size when <code>isInEditMode</code> it is still showing up as 0 height.</p>
  <p>Can someone point out what I'm doing wrong?
  This is the custom view class:</p>
  <pre><code>package com.classdojo.android.nessie
  
  import android.content.Context
  import android.util.AttributeSet
  import android.util.TypedValue
  import android.view.Gravity
  import android.view.View
  import android.view.ViewGroup
  import android.widget.LinearLayout
  import androidx.annotation.ColorRes
  import androidx.annotation.DimenRes
  import androidx.annotation.DrawableRes
  import androidx.core.content.res.ResourcesCompat
  import androidx.core.view.isVisible
  import com.airbnb.paris.utils.getFont
  import com.classdojo.android.nessie.icon.Icon
  import kotlinx.android.synthetic.main.nessie_button_view.view.*
  
  class NessieButton : LinearLayout {
  
      constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
          init(attrs)
      }
      constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) {
          init(attrs)
      }
      constructor(context: Context) : super(context) {
          init(null)
      }
  
      enum class Style(
          @DrawableRes
          val backgroundRes: Int,
          @ColorRes
          val textColor: Int
      ) {
          PRIMARY(
              backgroundRes = R.drawable.nessie_button_style_primary,
              textColor = R.color.nessie_button_style_primary_text_color
          ),
          SECONDARY(
              backgroundRes = R.drawable.nessie_button_style_secondary,
              textColor = R.color.nessie_button_style_secondary_text_color
          ),
          TERTIARY(
              backgroundRes = R.drawable.nessie_button_style_tertiary,
              textColor = R.color.nessie_button_style_tertiary_text_color
          ),
          DESTRUCTIVE(
              backgroundRes = R.drawable.nessie_button_style_destructive,
              textColor = R.color.nessie_button_style_destructive_text_color
          ),
          BEYOND(
              backgroundRes = R.drawable.nessie_button_style_beyond,
              textColor = R.color.nessie_button_style_beyond_text_color
          );
  
          companion object {
              fun from(index: Int) = values().getOrElse(index) { Style.PRIMARY }
          }
      }
  
      enum class Size(
          @DimenRes
          val horizontalPadding: Int,
          @DimenRes
          val verticalPadding: Int,
          @DimenRes
          val textSize: Int
      ) {
          SMALL(
              horizontalPadding = R.dimen.nessie_default_size_3x,
              verticalPadding = R.dimen.nessie_default_size_2x,
              textSize = R.dimen.nessie_textSizeDetail
          ),
          MEDIUM(
              horizontalPadding = R.dimen.nessie_default_size_3x,
              verticalPadding = R.dimen.nessie_default_size_2x,
              textSize = R.dimen.nessie_textSizeAction
          ),
          LARGE(
              horizontalPadding = R.dimen.nessie_default_size_4x,
              verticalPadding = R.dimen.nessie_default_size_3x,
              textSize = R.dimen.nessie_textSizeAction
          );
  
          companion object {
              fun from(index: Int) = values().getOrElse(index) { Size.LARGE }
          }
      }
  
      var text: CharSequence?
          set(value) {
              nessie_button_text_view.text = value
              nessie_button_text_view.isVisible = !value.isNullOrBlank()
          }
          get() = nessie_button_text_view.text
  
      var icon: Icon? = null
          set(value) {
              field = value
              when (value) {
                  null -&gt; {
                      nessie_button_icon_view.isVisible = false
                  }
                  else -&gt; {
                      nessie_button_icon_view.icon = value
                      nessie_button_icon_view.isVisible = true
                  }
              }
          }
  
      var style: Style = Style.PRIMARY
          set(value) {
              field = value
              setBackgroundResource(value.backgroundRes)
              val color = ResourcesCompat.getColor(resources, value.textColor, null)
              nessie_button_icon_view.iconColor = color
              nessie_button_text_view.setTextColor(color)
          }
  
      var size: Size = Size.LARGE
          set(value) {
              field = value
              val horizontalPadding = resources.getDimensionPixelSize(value.horizontalPadding)
              val verticalPadding = resources.getDimensionPixelSize(value.verticalPadding)
              setPadding(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding)
              val fontSize = resources.getDimension(value.textSize)
              nessie_button_text_view.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
              nessie_button_icon_view.apply {
                  iconPixelSize = fontSize.toInt()
                  layoutParams.apply {
                      width = fontSize.toInt()
                      height = fontSize.toInt()
                  }
              }
          }
  
      init {
          init(null)
      }
  
      override fun setEnabled(enabled: Boolean) {
          super.setEnabled(enabled)
          super.setFocusable(enabled)
  
          val colorStateList = ResourcesCompat.getColorStateList(resources, style.textColor, null)
          val viewState = drawableState
          val color = colorStateList!!.getColorForState(viewState, 0)
          nessie_button_text_view.setTextColor(color)
          nessie_button_icon_view.iconColor = color
      }
  
      private fun init(attrs: AttributeSet?) {
          orientation = LinearLayout.HORIZONTAL
          gravity = Gravity.CENTER
  
          inflate(context, R.layout.nessie_button_view, this)
  
          val styledAttributes = context.obtainStyledAttributes(attrs, R.styleable.nessie_NessieButton)
  
          try {
              val iconIndex = styledAttributes.getInteger(R.styleable.nessie_NessieButton_nessie_icon, -1)
              icon = when (iconIndex) {
                  -1 -&gt; null
                  else -&gt; Icon.from(iconIndex)
              }
              text = styledAttributes.getString(R.styleable.nessie_NessieButton_android_text)
              style = Style.from(styledAttributes.getInteger(R.styleable.nessie_NessieButton_nessie_buttonStyle, Style.PRIMARY.ordinal))
              size = Size.from(styledAttributes.getInteger(R.styleable.nessie_NessieButton_nessie_buttonSize, Size.LARGE.ordinal))
  
              isEnabled = styledAttributes.getBoolean(R.styleable.nessie_NessieButton_android_enabled, true)
          } finally {
              styledAttributes.recycle()
          }
  
          nessie_button_text_view.typeface = context.getFont(R.font.nessie_proximanova_bold)
      }
  
      override fun addView(child: View, index: Int, params: ViewGroup.LayoutParams?) {
          if (child.id == R.id.nessie_button_icon_view || child.id == R.id.nessie_button_text_view) {
              super.addView(child, index, params)
          } else {
              throw IllegalArgumentException(&quot;Cannot add more views to a NessieButton&quot;)
          }
      }
  }
  </code></pre>
  <p>And this is the view layout:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;merge xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:id=&quot;@+id/root_view&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:gravity=&quot;center&quot;
      android:orientation=&quot;horizontal&quot;
      android:padding=&quot;@dimen/nessie_default_size_2x&quot;
      tools:background=&quot;@drawable/nessie_button_primary_background&quot;
      tools:parentTag=&quot;android.widget.LinearLayout&quot;&gt;
  
      &lt;com.classdojo.android.nessie.icon.IconImageView
          android:id=&quot;@+id/nessie_button_icon_view&quot;
          android:layout_width=&quot;@dimen/nessie_default_size_3x&quot;
          android:layout_height=&quot;@dimen/nessie_default_size_3x&quot;
          android:layout_marginEnd=&quot;@dimen/nessie_default_size&quot; /&gt;
  
      &lt;TextView
          android:id=&quot;@+id/nessie_button_text_view&quot;
          style=&quot;@style/nessie_action&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:lineHeight=&quot;22sp&quot;
          android:textStyle=&quot;bold&quot;
          tools:text=&quot;My button&quot;
          tools:textColor=&quot;@color/nessie_white&quot; /&gt;
  
  &lt;/merge&gt;
  </code></pre>