我添加了一个ListPopupWindow
锚定到一个TextInputLayout
. 我遇到的问题是弹出窗口的动画开始于TextInputLayout
:
请注意,问题只是动画开始的地方。动画完成后,弹出窗口正确显示在TextInputLayout
.
我该怎么做才能让动画在TextInputLayout
? 请注意,这不是我自己的动画,而是默认动画。
布局片段:
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="hint" />
</com.google.android.material.textfield.TextInputLayout>
代码ListPopupWindow
:
val arrAdapter = ArrayAdapter<String>(
this,
R.layout.dropdown_menu_popup_item,
listOf("hello", "world")
)
val listPopupWindow = ListPopupWindow(this).apply {
anchorView = findViewById(R.id.textInputLayout)
setAdapter(arrAdapter)
}
findViewById<Button>(R.id.button).setOnClickListener {
listPopupWindow.show()
}
代码也可以在 Github 上找到:https ://github.com/wondering639/stack-listpopupwindow-animation-start
提示:这只是一个简化的测试用例。我知道AutoCompleteTextView
,但我确实需要手动显示ListPopupWindow
.