IconColor changes when Popup is dismissed
rtsketo opened this issue · 0 comments
rtsketo commented
popupMenu {
style = R.style.Widget_MPM_Menu_Custom
section { attachmentList?.forEach { item {
iconColor = Color.WHITE
labelColor = Color.WHITE
iconDrawable = it.icon
label = it.title
callback = { intent(it.url) }
} } }
where R.style.Widget_MPM_Menu_Custom
is <style name="Widget.MPM.Menu.Custom"><item name="android:colorBackground">#ffaf00</item></style>
The icons in the above example start white, but when one of them is selected or the dialog is dismissed, they turn black.
My solution was to repaint them on dismiss, like below.
val drawables = arrayListOf<Drawable>()
val popup = popupMenu {
style = R.style.Widget_MPM_Menu_Custom
dropDownVerticalOffset = toolBar.height
section { attachmentList?.forEach { item {
iconColor = white
labelColor = white
iconDrawable = it.icon
iconDrawable?.apply { drawables.add(this) }
label = it.title
callback = { intent(it.url) }
} } }
}
// Junky way to patch this bug.
popup.setOnDismissListener {
drawables.forEach { drawable ->
drawable.filter(white) } }
popup.show(context!!, it)