I need create fields edit page in app. There are list of EditText for edit Contact. For each field type i have an layout. As example - for name and last name it is float labeled edit text. For facebook - simple edit text with icon. I am creating this list with Android Data Binding Library
I've created layout
<data>
<variable
name="item"
type="app.core.db.model.Field" />
</data>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="65dp"
app:hintTextAppearance="@style/TextAppearence.App.TextInputLayout"
app:theme="@style/EditFieldFloatLabeled">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:hint="@{item.getHint()}"
android:imeOptions="actionNext"
android:maxLines="1" />
</android.support.design.widget.TextInputLayout>
</FrameLayout>
But float label not works. I starts commenting line by line to find out reason. Float label became work when I've commented line
android:hint="@{item.getHint()}
(And replace it with hardcoded text). getHint()
returns R.string.{something}
based on field type.
There I've found out than programmatically setting hint produce float label disappearing. I can not use static layout (instead recycler view) because fields list can increase dynsmically (ex: I am writing phone number in field and empty Phone field inserts after it for other phone number).
Is there way to create float label same way (by defining hint with field type)?