Reputation: 310
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>
Upvotes: 3
Views: 1852
Reputation: 1
In my experience, reading the Android documentation is a good first step. Emulators work well but you really want to get comfortable with the design patterns and interactions from an OS level.
If you or your company have test devices I would suggest using an Android phone for a few weeks. I used Android for everything excepts calls/texts. You'll start to pick up on subtle differences between iOS and Android. ex: Use of UIAlerts vs Toasts vs Dialogs
--
For resources check out: google.com/design/spec & http://blog.mengto.com/how-to-design-for-android-devices/ and Medium articles.
Documentation for Android is ok but the best way to learn is to pair with a designer who has designed for Android before. Even if it's just to learn the differences between iOS and Android you'll learn a bunch.
Upvotes: 0
Reputation: 4573
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.
Upvotes: 5