Skip to content

"Ch4 Toolbar+TabLayout" example with transparent NavigationBar #2

@patrickfrei

Description

@patrickfrei

Hello,

My app uses the same principles as the "Ch4 Toolbar+TabLayout" example on your page:

<CoordinatorLayout>
	<AppbarLayout>
	 	<Toolbar/>
   	 	<TabLayout/>
	</AppbarLayout>
	<ViewPager2/>
</CoordinatorLayout>

ViewPager2 acts as container for fragments. There is one fragment per tab. Each fragment includes a RecyclerView (scrollable list). Similar to your app.

Now, I've implemented fullscreen design with insets similar to example "Ch9 Insets and Fullscreen" in accordance with the Android guidelines within MainActivity.java. I've set mlp.bottomMargin to 0 and android:paddingBottom="50dp" to ViewPager2 in order the see the list scrolling behind the transparent navbar. So far so good.

The issue that I'm now facing is, that...

  1. an ugly white bar appears at the bottom of the screen when scrolling upwards and makes the NavBar intransparent again. See a video of the issue here.
  2. I don't like the hardcoded 50dp on ViewPager2 as different devices might have different paddings.

The solution would be to know the bottom NavBar inset within my fragments. Then, I could simply apply setPadding(0,0,0, navBarPadding); + setClipToPadding(false); to the Recyclerview and could remove the 50dp from ViewPager2. Unfortunately, I don't get that info via setOnApplyWindowInsetsListener in the fragment as the function is never called there.

Do you have any plans to implement a transparent NavBar to "Ch4 Toolbar+TabLayout" and / or would like to share some of your know-how about the issue that I'm facing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions