我已經與下面的代碼編程方式做到了這一點:
將這個你叫popup.show()
之前。
// Change PopupMenu subMenu title color
PopupMenu popup = new PopupMenu(activity, view);
Menu itemSetAs = popup.getMenu();
SubMenu s = itemSetAs.findItem(R.id.SetAs).getSubMenu();
SpannableString headerTitle = new SpannableString(itemSetAs.findItem(R.id.SetAs).getTitle());
// Change the color:
headerTitle.setSpan(new ForegroundColorSpan(Color.YOUR_COLOR), 0, headerTitle.length(), 0);
// You can even change the size:
int textSize = getResources().getDimensionPixelSize(R.dimen.your_size);
headerTitle.setSpan(new AbsoluteSizeSpan(textSize), 0, headerTitle.length(), SPAN_INCLUSIVE_INCLUSIVE);
s.setHeaderTitle(headerTitle);
popup.show().