Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
460 views
in Technique[技术] by (71.8m points)

android - TextInputLayout Hint doesn't float up after updating Google Support Library

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.

Here is my xml code:

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

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

This is the problem

enter image description here

You can clearly see that the hint is floating up.

Please guide.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...