YBDevi
YBDevi

Reputation: 479

Bottom navigation with navigation component when fragment load flickering happens

I am currently using bottom navigation with navigation component, it is working correctly but when we click on navigation item fragment is loading then flickering is happening, flicker is happen even current item selected also. It is happening when fragment is loading. My application screen background is not white when it is white no flickering is displaying i have try all available solutions.

I have change background color of google navigation sample application then also i am able to see the flicker.

If anyone have any solution please post here.

Upvotes: 4

Views: 2235

Answers (3)

Jay Patel
Jay Patel

Reputation: 104

Use these two lines in your Fragment Container.

android:layout_height="match_parent" app:layout_constraintBottom_toTopOf="@+id/nvBottomNavigationMenu"

Upvotes: 0

Wirling
Wirling

Reputation: 5375

The flickering happens because of the default crossfade animation that the bottom navigation uses. You can overwrite the animation by creating the following files in the res\animator package.

nav_default_enter_anim.xml
nav_default_exit_anim.xml
nav_default_pop_enter_anim.xml
nav_default_pop_exit_anim.xml

This should be the content of those files.

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- Overwrite the default animation. -->
</set>

Upvotes: 3

YBDevi
YBDevi

Reputation: 479

I have find solution for my problem i'm having flickering because my background color is black if i change it to white i didn't have any flicker for that i have update theme by adding bellow lines.

    <item name="android:windowBackground">#000000</item>
    <item name="android:colorBackground">#000000</item>

By adding these lines i have avoided the flicker problem.

Upvotes: 1

Related Questions