android - 为什么 float 提示动画不起作用?

标签 android xml android-layout android-animation android-textinputlayout

我首先需要这样的动画:

enter image description here

(来自 Internet 的 Gif)但是即使使用 app:hintAnimationEnabled="true" 动画也不起作用。始终是 gif 的第二个示例。可能是什么问题呢?我做错了什么?

<com.google.android.material.textfield.TextInputLayout
    android:id="@+id/textInputLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Login"
    app:hintEnabled="true"
    app:hintAnimationEnabled="true">

    <com.google.android.material.textfield.TextInputEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</com.google.android.material.textfield.TextInputLayout>

最佳答案

您还需要为 TextInputLayout 设置提示才能使动画正常工作,我只尝试动态设置提示按预期工作,请先尝试在 xml 中设置提示以查看它是否有效,如果没有则执行它是动态的:

TextInputLayout inputLayout = findViewById(R.id.textInputLayout);
inoutLayout.setHint("Hint");

关于android - 为什么 float 提示动画不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57345776/

相关文章:

android - Android 4.x 中的 TextView 字体

java - 此行有多个标记 - token 语法错误 ";", , expected

java - 在zxing条码扫描枪上添加两条短信/提示信息

android - Google+ 登录 : Google Play Services out of date exception

android - Glide Library for Android 中的 HTTPS 图片

java - 是否可以为 javax.xml.parsers.DocumentBuilder.parse(File) 提供进度报告?

android - android解析xml报空指针异常

ruby-on-rails - 同一行上的两个索引

android - 如何从我的应用程序中删除标题栏?

java - TextView setText View 中的空指针异常被夸大