android - 更新 Google 支持库后,TextInputLayout 提示不会 float

标签 android android-support-library android-textinputlayout

我最近将我的支持库更新为 com.android.support:appcompat-v7:25.1.0 之后,如果我通过 xml 文件将文本添加到 EditText TextInputLayout 提示不 float 。

我也看过this question但它对我不起作用。

这是我的 xml 代码:

<android.support.design.widget.TextInputLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="16dp"
        android:layout_marginEnd="16dp"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginRight="16dp"
        app:layout_constraintVertical_bias="0.0"
        android:id="@+id/til1"
        android:layout_marginStart="16dp"
        app:layout_constraintLeft_toLeftOf="parent"
        android:layout_marginLeft="16dp"
        app:layout_constraintHorizontal_bias="0.33">

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="From"
            android:inputType="time"
            android:text="09:00 AM"
            android:id="@+id/from_mon"
            android:textSize="14sp" />
    </android.support.design.widget.TextInputLayout> 

这是我的 gradle 依赖项:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.1.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
    compile 'uk.co.chrisjenx:calligraphy:2.2.0'
    compile 'com.android.support:design:25.1.0'
    compile 'com.android.support:support-v4:25.1.0'
    compile 'com.android.support:recyclerview-v7:25.1.0'
    compile 'com.android.support:cardview-v7:25.1.0'
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.github.bhargavms:DotLoader:1.0.1'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.labo.kaji:fragmentanimations:0.1.1'
    compile 'com.github.esafirm.android-image-picker:imagepicker:1.2.5'
    testCompile 'junit:junit:4.12'
}

这就是问题所在

enter image description here

可以清楚的看到提示是飘起来的。

请指导。

最佳答案

您必须向 TextInputLayout 提供提示并使用 TextInputEditText 而不是 EditText

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

    <android.support.v7.widget.TextInputEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="09:00 AM" />
</android.support.design.widget.TextInputLayout>

关于android - 更新 Google 支持库后,TextInputLayout 提示不会 float ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41135968/

相关文章:

android - Google Play 控制台中针对被拒绝应用的更新 APK 选项在哪里?

android - 在 Android 10 中,当以编程方式打开位置时,我得到结果代码 RESULT_CANCELED

Android 项目和 Gradle : assemble a single module

android - Android-无法解决:cardview-v7

android - 在 Eclipse 中使用支持设计库

java - 如何更改TextInputEditText的底线颜色和提示颜色?

java - Android - fragment 中两个按钮中的第二个按钮无响应

android - 更新支持库的最佳方式

android - 使用 TextInputLayout 和 Spinner 的对齐问题

android - 文本输入布局 : RuntimeException - Failed to resolve attribute at index 24