Android Navigation Bar covering viewpager content

Wrap ViewPager into ConstraintLayout then, set to your viewpager:

app:layout_constraintBottom_toBottomOf="parent"

that should work


I Figured it out. In my particular situation each of my fragments manage their own toolbar instance. I was calling setSupportActionBar() in the onViewCreated() method on my fragments. Moving this functionality into onCreateView() solved it.

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_my_account, container, false);
        setupToolbar((Toolbar) view.findViewById(R.id.toolbar));
        return view;
    }

    private void setupToolbar(Toolbar toolbar) {
        toolbarController.registerToolbar(toolbar);
        toolbarController.setActivityTitle("My Account");
    }

(registerToolbar() calls setSupportActionBar() inside the hosting activity).

Hope this helps everyone!


Viewpager's fragment root view has to be RecyclerView or NestedScrollView. FrameLayout doesn't support scrolling behavior of CoordinatorLayout and this is why it doesn't work well.

How you can fix the viewpager's fragment layout: don't wrap RecyclerView inside FrameLayout. Instead declare RecyclerView at the root. You also can set padding="8dp" on RecyclerView, just use android:clipToPadding="false".