【问题标题】:Why floating hint animation doesn't work?为什么浮动提示动画不起作用?
【发布时间】:2019-08-04 10:27:12
【问题描述】:

我首先需要像这样的动画:

(来自 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>

【问题讨论】:

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


    【解决方案1】:

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

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

    【讨论】:

    • 我都试过了。为TextInputLayout 和代码setHint() 设置提示。两者都不起作用。
    • 对,一删二试
    猜你喜欢
    • 1970-01-01
    • 2015-07-15
    • 2020-08-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多