gpt4 book ai didi

android - 如何更改弹出菜单背景的颜色

转载 作者:行者123 更新时间:2023-11-29 17:36:34 25 4
gpt4 key购买 nike

我正在使用以下代码创建弹出菜单..我需要更改菜单的背景颜色。我该怎么做。请帮忙。

//Creating the instance of PopupMenu  
PopupMenu popup = new PopupMenu(ctx, holder.ll_overflow);
//Inflating the Popup using xml file
popup.getMenuInflater().inflate(R.menu.bday_contacts_menu, popup.getMenu());

//registering popup with OnMenuItemClickListener
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

@Override
public boolean onMenuItemClick(MenuItem item) {



return true;
}

});

popup.show();//showing popup menu

最佳答案

你可以使用样式改变它

   <style name="AppBaseTheme" parent="@android:style/Theme.Light.NoTitleBar">

</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:popupMenuStyle">@style/PopupMenu</item>
</style>

<style name="PopupMenu" parent="@android:style/Widget.PopupMenu">
<item name="android:popupBackground">@android:color/white</item>
<item name="android:textColor">#FF01F0</item>
<item name="android:textSize">12sp</item>
</style>

关于android - 如何更改弹出菜单背景的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30239012/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com