更新Google支持库后,TextInputLayout提示不会浮动

Rah*_*rma 7 android android-support-library android-textinputlayout

我最近更新了我的支持库,com.android.support:appcompat-v7:25.1.0之后如果我将文本添加到EditTextvia xml文件中,则TextInputLayout提示不会浮动.

我也看过这个问题,但它对我不起作用.

这是我的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> 
Run Code Online (Sandbox Code Playgroud)

这是我的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'
}
Run Code Online (Sandbox Code Playgroud)

这就是问题

在此输入图像描述

您可以清楚地看到提示正在浮动.

请指导.

Dee*_*yal 11

您必须提供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>
Run Code Online (Sandbox Code Playgroud)


Lea*_*ays -2

检查你在 build.gradle 中进行这样的更改以获取依赖项..我认为 gradle 不是问题

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.1.1'
    compile 'com.android.support:design:24.1.1'

}
Run Code Online (Sandbox Code Playgroud)

如果不能通过更改 gradle 更改来解决,请首先检查输入布局中的基本更改.. 在进行更改后,它会挑衅地使您的文本浮动。

 <android.support.design.widget.TextInputLayout
                    android:id="@+id/til1"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:focusableInTouchMode="true"
                    android:layout_margin="10dp">


    <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>
Run Code Online (Sandbox Code Playgroud)

注意:如果可能的话,将提示设置为字符串文件..可能这也是问题所在。