TextInputLayout 不显示浮动文本

TextInput Layout not show floating text

我在使用 TextInputLayout 时遇到问题,它在首次加载时(在 edittext 中有一些文本)不会在 EditText 上方显示提示文本,如下所示

我在使用这个库时遇到问题 https://github.com/braintree/android-card-form。通常 TextInputLayout 是这样的(当我还没有添加这个库时)。我不知道这个库的哪种风格导致了这个问题(也许它覆盖了一些字段)。

感谢您的帮助。

使用这个库,它可以很好地用于此目的:

compile 'com.android.support:design:24.1.1'

示例:

 <android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <EditText
                android:id="@+id/txtUsername"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:drawableLeft="@drawable/user"
                android:drawableTint="#FF4081"
                android:hint="User Name"
                android:inputType="textEmailAddress"
                android:maxLines="1" />
        </android.support.design.widget.TextInputLayout>

我通过更改那个库解决了这个问题 compile 'com.android.support:design:[25.0.0,26.0.0)' 到 编译 'com.android.support:design:25.0.1' 并作为模块添加到我的项目中。

这个问题的原因是:我使用 appcompat-v7:25.0.1 但是当我使用 gradle compile 'com.braintreepayments:card-form:3.0.3' 时,设计支持库更改为 25.1.0 并导致该问题。我换了同版本的appcombat,desgin支持librares。