title: java.lang.ClassCastException when trying to add constraints to textview
body: <p>I'm programmatically creating a constraint layout and adding a text view to it, but when I try to add the constraints it raises a <code>java.lang.ClassCastException</code> exception. Here is my code:</p>
  <pre><code>var textlayoutbottom = ConstraintLayout(this)
                      textlayout.addView(textlayoutbottom)
  
                      var typelabel = TextView(this)
                      textlayoutbottom.addView(typelabel)
  
                      textlayoutbottom.layoutParams = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT)
  
                      typelabel.text = getAnimeType(anime.type)
  
                      var params = typelabel.layoutParams as ConstraintLayout.LayoutParams
                      params.leftToLeft = textlayoutbottom.id
                      params.bottomToBottom = textlayoutbottom.id
                      typelabel.requestLayout()
  </code></pre>
  <p>But the app crashes and it doesn't even show the error line.</p>
  <p>Here is my log:</p>
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.my.package, PID: 5234
      java.lang.ClassCastException: androidx.constraintlayout.widget.ConstraintLayout$LayoutParams cannot be cast to android.widget.LinearLayout$LayoutParams
          at android.widget.LinearLayout.measureVertical(LinearLayout.java:731)
          at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
          at android.view.View.measure(View.java:19857)
          at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
          at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
          at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1117)
          at android.widget.LinearLayout.onMeasure(LinearLayout.java:642)
          at android.view.View.measure(View.java:19857)
          at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
          at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
          at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
          at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
          at android.view.View.measure(View.java:19857)
          at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
          at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
          at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
          at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
          at android.view.View.measure(View.java:19857)
          at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:1293)
          at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
          at android.widget.ScrollView.onMeasure(ScrollView.java:340)
          at android.view.View.measure(View.java:19857)
          at androidx.constraintlayout.widget.ConstraintLayout$Measurer.measure(ConstraintLayout.java:792)
          at androidx.constraintlayout.solver.widgets.ConstraintWidgetContainer.measure(ConstraintWidgetContainer.java:583)
          at androidx.constraintlayout.solver.widgets.ConstraintWidgetContainer.layout(ConstraintWidgetContainer.java:682)
          at androidx.constraintlayout.solver.widgets.analyzer.BasicMeasure.solveLinearSystem(BasicMeasure.java:159)
          at androidx.constraintlayout.solver.widgets.analyzer.BasicMeasure.solverMeasure(BasicMeasure.java:290)
          at androidx.constraintlayout.solver.widgets.ConstraintWidgetContainer.measure(ConstraintWidgetContainer.java:119)
          at androidx.constraintlayout.widget.ConstraintLayout.resolveSystem(ConstraintLayout.java:1578)
          at androidx.constraintlayout.widget.ConstraintLayout.onMeasure(ConstraintLayout.java:1690)
          at android.view.View.measure(View.java:19857)
          at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
          at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
          at androidx.appcompat.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:146)
          at android.view.View.measure(View.java:19857)
          at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
          at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
          at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
          at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
          at android.view.View.measure(View.java:19857)
          at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
          at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
          at android.view.View.measure(View.java:19857)
          at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
          at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
          at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
          at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
          at android.view.View.measure(View.java:19857)
          at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
          at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
          at com.android.internal.policy.DecorView.onMeasure(DecorView.java:689)
          at android.view.View.measure(View.java:19857)
          at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2275)
  E/AndroidRuntime:     at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1366)
          at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1619)
          at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254)
          at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6337)
          at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874)
          at android.view.Choreographer.doCallbacks(Choreographer.java:686)
          at android.view.Choreographer.doFrame(Choreographer.java:621)
          at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860)
          at android.os.Handler.handleCallback(Handler.java:751)
          at android.os.Handler.dispatchMessage(Handler.java:95)
          at android.os.Looper.loop(Looper.java:154)
          at android.app.ActivityThread.main(ActivityThread.java:6119)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
  </code></pre>
  <p>Any ideas?</p>