TextInput布局不显示浮动文本

时间:2017-01-13 15:20:33

标签: android android-edittext android-textinputlayout

我遇到TextInputLayout问题,第一次加载(在edittext中有一些文本)时,它没有在EditText上面显示提示文本

enter image description here

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

enter image description here

感谢您的帮助。

2 个答案:

答案 0 :(得分:1)

使用此库可以正常工作:

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>

答案 1 :(得分:0)

我通过更改该库来修复此问题 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。