Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using design support library with constraint layout

I'm tried to use TextInputLayout from support design library within ConstraintLayout, but got a error:

android.widget.LinearLayout$LayoutParams 
cannot be cast to android.support.constraint.ConstraintLayout$LayoutParams

How can I achieve the same functionality as support.design.widget.TextInputLayout but with ConstraintLayout?

Full layout is here: http://pastebin.com/TjC0FAdS

Problem is:

<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>
like image 495
Max Plakhuta Avatar asked Mar 22 '26 23:03

Max Plakhuta


1 Answers

Attributes such as app:layout_constraintLeft_toRightOf require ConstraintLayout to be a parent view. Move those attributes to the TextInputLayout and it should work fine.

like image 142
Gennadii Saprykin Avatar answered Mar 26 '26 08:03

Gennadii Saprykin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!