I am using recently released Android Design Support Library to show floating label with EditTexts. But i am facing the problem that the Hint on the EditText is not showing w
Update:
This is a bug that has been fixed in version 22.2.1 of the library.
Original Answer:
As mentioned by @shkschneider, this is a known bug. Github user @ljubisa987 recently posted a Gist for a workaround:
https://gist.github.com/ljubisa987/e33cd5597da07172c55d
As noted in the comments, the workaround only works on Android Lollipop and older. It does not work on the Android M Preview.
There is a simple solution to this as this worked for me
<android.support.design.widget.TextInputLayout
android:id="@+id/activity_login_til_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="27dp"
android:layout_marginTop="24dp"
android:padding="10dp"
app:passwordToggleEnabled="true"
app:passwordToggleTint="#000000"
app:passwordToggleDrawable="@drawable/passwordviewtoggleselector"
android:theme="@style/Base.TextAppearance.AppCompat">
<!---- add this line and theme as you need ----->
<android.support.design.widget.TextInputEditText
android:id="@+id/activity_login_et_password"
android:layout_width="match_parent"
android:layout_height="58dp"
android:hint="Password"
android:inputType="textPassword"
android:padding="10dp"
android:textColor="#f5ab3a"
android:textColorHint="#e6d2d1cf"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
Just add android:theme="@style/Base.TextAppearance.AppCompat" to the TextEditLayout and it should work and you can change the theme as you need.
Looks like this issue appears when you set onFousListener on EditText - try to extend EditText and support multiple onFocusListeners
Just add: android:hint="your_hint"
for TextInputLayout
.
That is a known bug of the Android Design library. It has been accepted and assigned.
So you should have this fixed in the next Android Design library release.
In the meantime, you could watch the issue tracker for a hacky-fix that might get posted there, but I don't know any as of now.
And yes, it only affect Lollipop and above.
This works for me in Design Library 23.1.1:
Set the hint color in xml attributes of TextInputLayout:
<android.support.design.widget.TextInputLayout
....
android:layout_margin="15dp"
android:textColorHint="@color/hintColor"
android:layout_width="match_parent"
...