Open rtsketo opened 4 years ago
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) } } } }
R.style.Widget_MPM_Menu_Custom
<style name="Widget.MPM.Menu.Custom"><item name="android:colorBackground">#ffaf00</item></style>
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)
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.