我尝试使用 ConstraintLayout 中支持设计库中的 TextInputLayout,但出现错误:
android.widget.LinearLayout$LayoutParams
cannot be cast to android.support.constraint.ConstraintLayout$LayoutParams
如何使用 ConstraintLayout 实现与 support.design.widget.TextInputLayout 相同的功能?
完整版面在这里: http: //pastebin.com/TjC0FAdS
问题是:
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/constraintLayout">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<AutoCompleteTextView
android:layout_width="0dp"
android:layout_height="0dp"
android:singleLine="true"
android:id="@+id/email"
android:hint="@string/prompt_email"
app:layout_constraintLeft_toRightOf="@+id/imageView3"
android:layout_marginStart="8dp"
app:layout_constraintTop_toBottomOf="@+id/logo"
android:layout_marginTop="16dp"
app:layout_constraintRight_toRightOf="@+id/constraintLayout"
android:layout_marginEnd="16dp" />
</android.support.design.widget.TextInputLayout>
</android.support.constraint.ConstraintLayout>