更新Google支持库后,TextInputLayout提示不浮动 [英] TextInputLayout Hint doesn't float up after updating Google Support Library

查看:153
本文介绍了更新Google支持库后,TextInputLayout提示不浮动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近将支持库更新为com.android.support:appcompat-v7:25.1.0,此后,如果我通过xml文件向EditText添加文本,则TextInputLayout提示不会浮动.

I recently updated my support library to com.android.support:appcompat-v7:25.1.0 after which if I add a text to EditText via xml file the TextInputLayout hint doesn't float up.

我还查看了问题,但这对我没有用.

I also had a look at this question but it didn't worked for me.

这是我的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依赖项:

Here is my gradle dependencies:

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'
}

这是问题

您可以清楚地看到提示是浮动的.

You can clearly see that the hint is floating up.

请指导.

推荐答案

您必须向 TextInputLayout 提供提示,并使用 TextInputEditText 代替 EditText >

You must provide hint to the TextInputLayout and use TextInputEditText instead of 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>

这篇关于更新Google支持库后,TextInputLayout提示不浮动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆