BottomSheetDialogFragment: how to prevent NavigationBar dimming

一曲冷凌霜 提交于 2019-12-11 02:56:26

问题


in my theme for API 27 I want to have a white navigation bar, which works fine, but when I show my bottomSheetDialogFragment the system dimmend my navigation bar like in a Dialog. Is it without the new components from the new material theme possible to prevent the dimming from the navigation bar? Here are some code snippets:

// 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;
    }
}

// Show 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);
        }
    }

I Finally find a solution by ma self:

Prevent BottomSheetDialogFragment covering navigation bar

来源:https://stackoverflow.com/questions/50888007/bottomsheetdialogfragment-how-to-prevent-navigationbar-dimming

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!