在我的API 27主题中,我希望有一个白色导航栏,它可以正常工作,但当我显示我的bottomSheetDialogFragment时,系统会像对话框一样调整我的导航栏。是否没有新材料主题的新组件可以防止导航栏变暗? 以下是一些代码段:
// Theme API 27
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowLightNavigationBar">true</item>
<item name="android:navigationBarColor">@android:color/white</item>
<item name="android:navigationBarDividerColor">@color/colorDivider</item>
</style>
// BottomSheet
public class MenuBottomSheet extends BottomSheetDialogFragment {
public static MenuBottomSheet newInstance(Bundle bundle) {
MenuBottomSheet sheet = new MenuBottomSheet();
sheet.setArguments(bundle);
return sheet;
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.sheet_menu, container, false);
View sheetLayout = view.findViewById(R.id.sheet_menu_layout);
final BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(sheetLayout);
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
return view;
}
}
//显示BottomSheet
private void showItemMenu(final Bundle args) {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager != null) {
MenuBottomSheet menuSheet = MenuBottomSheet.newInstance(args);
menuSheet.setTargetFragment(this, REQUEST_CODE);
menuSheet.show(fragmentManager, null);
}
}
我终于找到了ma self的解决方案: