我首先需要这样的动画:
(来自 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/