图标和文字同时显示
@SuppressLint("RestrictedApi")
private fun initMenu() {
var menu = toolbar?.getMenu()
if (menu is MenuBuilder) {
//设置图标文字同时显示
menu.setOptionalIconsVisible(true)
}
//设置右边更多按钮(三个点)为黑色
var moreIcon = ContextCompat.getDrawable(this, R.drawable.abc_ic_menu_overflow_material);
if(moreIcon != null) {
moreIcon.setColorFilter(ContextCompat.getColor(this, R.color.color_black), PorterDuff.Mode.SRC_ATOP)
toolbar?.setOverflowIcon(moreIcon)
}
} @SuppressLint("RestrictedApi")