Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 549
Rahul Sharma Avatar asked Dec 14 '16 06:12

Rahul Sharma


People also ask

How do you set different gravity for TextInputLayout hint and text in Android?

To set a different gravity for the EditText , don't set any gravity attributes in the layout, then set the EditText 's gravity programmatically, in your code. That is, after setContentView() , use findViewById() to get the EditText , then call setGravity(Gravity. CENTER_HORIZONTAL) on it.

How do I get rid of TextInputLayout padding?

You can remove extra space above AppCompatEditText by setting app:hintEnabled="false" to TextInputLayout but it won't display hint until you re-enable that.


2 Answers

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>
like image 72
Deepak Goyal Avatar answered Sep 28 '22 20:09

Deepak Goyal


After updating to version 25.1.0 of the v7 appcompat library, I faced many serious bugs in Toolbar, RecyclerView, etc.

I went back to version 25.0.1.

like image 33
Mahmood Abudaqa Avatar answered Sep 28 '22 20:09

Mahmood Abudaqa