BottomSheetDialogFragment:如何防止NavigationBar调光

时间:2018-06-16 12:43:06

标签: android bottom-sheet

在我的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的解决方案:

Prevent BottomSheetDialogFragment covering navigation bar

0 个答案:

没有答案