Android 添加TextInputLayout后,什么可能导致ClassCastException

Android 添加TextInputLayout后,什么可能导致ClassCastException,android,layout,android-constraintlayout,textinputlayout,Android,Layout,Android Constraintlayout,Textinputlayout,我在EditText字段中添加了一堆TextInputLayout包装器。 我有个例外 ClassCastException: android.widget.FrameLayout$LayoutParams cannot be cast to androidx.constraintlayout.widget.ConstraintLayout$LayoutParams 什么原因可能导致这种情况?约束布局中的另一个元素以前引用EditText的id作为其定位参考。必须将其更改为引用现在包含Edit

我在EditText字段中添加了一堆TextInputLayout包装器。 我有个例外

ClassCastException: android.widget.FrameLayout$LayoutParams cannot be cast to androidx.constraintlayout.widget.ConstraintLayout$LayoutParams

什么原因可能导致这种情况?

约束布局中的另一个元素以前引用EditText的id作为其定位参考。必须将其更改为引用现在包含EditText的TextInputLayout的id。
Android Studio确实在资源文件文本中用红色标记了引用,但我必须向下滚动才能看到它,并且在我构建项目时它没有显示任何内容(或者我没有看到任何内容)。

基本上,您应该根据父级选择
LayoutParams
。在本例中,您可能使用了
FrameLayout.LayoutParams
而不是
ConstraintLayout.LayoutParams