Problem and Solutions
How do I get the bottom navigation bar height for Material Design 3 in android ?
By M.K. Verma · 4 May 2022

Maybe you can try to get the height programmatically and set margin bottom dynamically during runtime?
Resources resources = context.getResources();
int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
if (resourceId > 0) {
navBar.getLayoutParams().height = resources.getDimensionPixelSize(resourceId);