8

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.

Community
  • 1
  • 1
Rahul Sharma
  • 2,867
  • 2
  • 27
  • 40
  • 1
    That seems like a serious bug. I don't have access to the latest source atm, but maybe they changed the required `EditText` class. Try using a `TextInputEditText`. – Mike M. Dec 14 '16 at 06:21
  • @MikeM. Same issue with TextInputEditText. – Rahul Sharma Dec 14 '16 at 06:26
  • 1
    Yep, it's a known problem apparently: http://code.google.com/p/android/issues/detail?id=230171&q=TextInputLayout&sort=-opened&colspec=ID%20Status%20Priority%20Owner%20Summary%20Stars%20Reporter%20Opened. If you really want to use that library version, it seems like a workaround is to set the text in your code. Not ideal, but it might be a bit before it's looked into, since it just got reported about 10 hours ago. – Mike M. Dec 14 '16 at 06:33
  • There seems to be more issues soething i came across on twitter.https://twitter.com/zarahjutz/status/807792883822563328 – Raghunandan Dec 14 '16 at 06:34
  • Ha! ^That's kinda funny.^ Yeah, I'd just revert your library version for now. – Mike M. Dec 14 '16 at 06:37
  • @Raghunandan that's horrible. – Rahul Sharma Dec 14 '16 at 06:40
  • @MikeM. seems like I don't have any option. I have to revert it back to previous one. – Rahul Sharma Dec 14 '16 at 06:40

6 Answers6

13

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>
Deepak Goyal
  • 4,747
  • 2
  • 21
  • 46
  • This should be the accepted answer. This is working for me with `25.2.0` – The Nomad Mar 16 '17 at 06:14
  • 1
    Great, another piece of outdated documentation - `TextInputLayout` javadoc still tells us to put the hint into the `TextInputEditText`... Don't fall for that. ;) – ubuntudroid Aug 14 '17 at 12:49
4

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.

Mike M.
  • 38,532
  • 8
  • 99
  • 95
3

UPDATE: The issue was fixed in 25.3.1

It is a bug in 25.1.0 https://code.google.com/p/android/issues/detail?id=230171 It seems we have to use previous 25.0.1 version for now.

3akat
  • 164
  • 2
  • 6
1

@Rahul Sharma,

Why you are using android:hint="From" and android:text="09:00 AM" in EditText tag of xml file?

Instead of that you can use only android:hint="From in xml file and In Java code u can set text in dynamically.

I hope u will get my point. Thanks.

kgsharathkumar
  • 1,369
  • 1
  • 19
  • 36
1

This issue is fixed in Support Library Version 25.2.0. Please update to 25.2.0 This update includes other major fixes.

https://developer.android.com/topic/libraries/support-library/revisions.html#25-2-0

Lavakush
  • 1,910
  • 2
  • 11
  • 14
-2

Check your Do changes like this in you build.gradle for dependencies .. I think gradle is not a problem

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'

}

If not solve by changes of gradle change First check basic changes in you inpul layout .. it will defiantly do your text float.. after do your changes.

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

NOTE: And if possible set your hint in to string file .. may that will also be the issue.

Learning Always
  • 1,563
  • 4
  • 29
  • 49
  • 1
    I already updated my support library to `com.android.support:appcompat-v7:25.1.0` why should I go back to `com.android.support:appcompat-v7:24.1.1`? – Rahul Sharma Dec 14 '16 at 06:30
  • dont go back just check my Text in put layout code and change it will work .. I tried from my side – Learning Always Dec 14 '16 at 06:31
  • Its the same code I am implementing and its **not working** with `com.android.support:appcompat-v7:25.1.0` support library. – Rahul Sharma Dec 14 '16 at 06:35
  • Okay.. as per Mike. M Comment Yes it is issue with appcompact com.android.support:appcompat-v7:25.1.0 support library. – Learning Always Dec 14 '16 at 06:36