CopyAndPasteHub / Android

Android files
19 stars 49 forks source link

More than 3 tabs will effect overall design #1

Open mohdhise opened 7 years ago

mohdhise commented 7 years ago

i tried to add more than 3 tabs, design look like weird...effect the screenshot_1 height of design...any solutions for this?

roushankumar01 commented 6 years ago

Use Shift mode Create this Method

@SuppressLint("RestrictedApi") private void disableShiftMode(BottomNavigationView view) { BottomNavigationMenuView menuView = (BottomNavigationMenuView) view.getChildAt(0); try { Field shiftingMode = menuView.getClass().getDeclaredField("mShiftingMode"); shiftingMode.setAccessible(true); shiftingMode.setBoolean(menuView, false); shiftingMode.setAccessible(false); for (int i = 0; i < menuView.getChildCount(); i++) { BottomNavigationItemView item = (BottomNavigationItemView) menuView.getChildAt(i); item.setShiftingMode(false); // set once again checked value, so view will be updated item.setChecked(item.getItemData().isChecked()); } } catch (NoSuchFieldException e) { Log.e("BNVHelper", "Unable to get shift mode field", e); } catch (IllegalAccessException e) { Log.e("BNVHelper", "Unable to change value of shift mode", e); } }

Call In inCreate and pass Nav View

navView = (BottomNavigationView) findViewById(R.id.home_nav); disableShiftMode(navView);

Shrejal-Joshi commented 4 years ago

hey I couldn't understand the code please give brief description of code as soon as possible

Use Shift mode Create this Method

@SuppressLint("RestrictedApi") private void disableShiftMode(BottomNavigationView view) { BottomNavigationMenuView menuView = (BottomNavigationMenuView) view.getChildAt(0); try { Field shiftingMode = menuView.getClass().getDeclaredField("mShiftingMode"); shiftingMode.setAccessible(true); shiftingMode.setBoolean(menuView, false); shiftingMode.setAccessible(false); for (int i = 0; i < menuView.getChildCount(); i++) { BottomNavigationItemView item = (BottomNavigationItemView) menuView.getChildAt(i); item.setShiftingMode(false); // set once again checked value, so view will be updated item.setChecked(item.getItemData().isChecked()); } } catch (NoSuchFieldException e) { Log.e("BNVHelper", "Unable to get shift mode field", e); } catch (IllegalAccessException e) { Log.e("BNVHelper", "Unable to change value of shift mode", e); } }

Call In inCreate and pass Nav View

navView = (BottomNavigationView) findViewById(R.id.home_nav); disableShiftMode(navView);