【发布时间】:2018-05-14 07:36:23
【问题描述】:
我的PopupWindow 需要一个浅色主题,所以我尝试使用ContextThemeWrapper 更改它:
if (R.id.action_filter == item.getItemId()) {
View filterView = getActivity().findViewById(R.id.action_filter);
assert filterView != null;
Context context = new ContextThemeWrapper(filterView.getContext(),
R.style.ThemeOverlay_AppCompat_ActionBar);
FilterWindow menu = new FilterWindow(context); //PopupWindow
menu.showAsDropDown(filterView, 0, -filterView.getHeight());
return true;
}
private static class FilterWindow extends PopupWindow {
FilterWindow(Context context) {
super(context);
LayoutInflater inflater = LayoutInflater.from(context);
View view = inflater.inflate(R.layout.menu_filter, null);
setContentView(view);
setOutsideTouchable(true);
setFocusable(true);
}
}
但它不起作用......我尝试了不同的风格,但我的背景总是黑色的。如何设置浅色主题?
【问题讨论】:
标签: android android-appcompat android-styles