package com.eightbitlab.test;

import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;

import com.eightbitlab.bottomnavigationbar.BottomBarItem;
import com.eightbitlab.bottomnavigationbar.BottomNavigationBar;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        TextView textView = ((TextView) findViewById(R.id.textView));
        showContent(0, textView);
        setupBottomBar(textView);
    }

    private void setupBottomBar(@NonNull final TextView textView) {
        BottomNavigationBar bottomNavigationBar = (BottomNavigationBar) findViewById(R.id.bottom_bar);

        BottomBarItem item = new BottomBarItem(R.drawable.test_icon, R.string.title);

        bottomNavigationBar
                .addTab(item)
                .addTab(item)
                .addTab(item)
                .addTab(item);

        bottomNavigationBar.setOnSelectListener(new BottomNavigationBar.OnSelectListener() {
            @Override
            public void onSelect(int position) {
                showContent(position, textView);
            }
        });

        //only for translucent system navbar
        if (atLeastKitkat() && isInPortrait()) {
            //if your bottom bar has fixed height
            //you'll need to increase its height as well
            bottomNavigationBar.setPadding(0, 0, 0, getSystemNavigationBarHeight());
        }
    }

    private boolean isInPortrait() {
        return getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
    }

    private boolean atLeastKitkat() {
        return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
    }

    void showContent(int position, @NonNull TextView textView) {
        textView.setText("Tab " + position + " selected");
    }

    private int getSystemNavigationBarHeight() {
        Resources res = getResources();

        int identifier = res.getIdentifier("navigation_bar_height", "dimen", "android");
        int height = 0;

        if (identifier > 0) {
            height = res.getDimensionPixelSize(identifier);
        }

        return height;
    }
}

@@ -24,16 +24,48 @@
 .test;%0A%0A
+import android.content.Context;%0A
 import a
@@ -279,16 +279,222 @@
 tivity;%0A
+import android.util.DisplayMetrics;%0Aimport android.view.Display;%0Aimport android.view.KeyCharacterMap;%0Aimport android.view.KeyEvent;%0Aimport android.view.ViewConfiguration;%0Aimport android.view.WindowManager;%0A
 import a
@@ -1715,39 +1715,37 @@
 if (
-atLeastKitkat() && isInPortrait
+shouldAddNavigationBarPadding
 ()) 
@@ -1947,32 +1947,171 @@
        %7D%0A    %7D%0A%0A
+    private boolean shouldAddNavigationBarPadding() %7B%0A        return atLeastKitkat() && isInPortrait() && hasSystemNavigationBar();%0A    %7D%0A%0A
     private bool
@@ -2586,24 +2586,16 @@
   int id
-entifier
  = res.g
@@ -2692,24 +2692,16 @@
   if (id
-entifier
  %3E 0) %7B%0A
@@ -2749,24 +2749,16 @@
 lSize(id
-entifier
 );%0A     
@@ -2785,16 +2785,1055 @@
  height;
+%0A    %7D%0A%0A    private boolean hasSystemNavigationBar() %7B%0A        if (Build.VERSION.SDK_INT %3E= Build.VERSION_CODES.JELLY_BEAN_MR1) %7B%0A            Display d = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();%0A%0A            DisplayMetrics realDisplayMetrics = new DisplayMetrics();%0A            d.getRealMetrics(realDisplayMetrics);%0A%0A            int realHeight = realDisplayMetrics.heightPixels;%0A            int realWidth = realDisplayMetrics.widthPixels;%0A%0A            DisplayMetrics displayMetrics = new DisplayMetrics();%0A            d.getMetrics(displayMetrics);%0A%0A            int displayHeight = displayMetrics.heightPixels;%0A            int displayWidth = displayMetrics.widthPixels;%0A%0A            return (realWidth - displayWidth) %3E 0 %7C%7C (realHeight - displayHeight) %3E 0;%0A        %7D else %7B%0A            boolean hasMenuKey = ViewConfiguration.get(this).hasPermanentMenuKey();%0A            boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);%0A            return !hasMenuKey && !hasBackKey;%0A        %7D
 %0A    %7D%0A%7D

Add navigation bar padding only if device has software navbar