Updated 13 January 2018
BottomNavigationView is a class which is used in Android to provide user a better and easier way to switch between the top-level views in a single tap. I am assuming that you are aware of BottomNavigationView, If you are not then I suggest you go through the below-provided blog link to better understand this blog. We will be directly discussing the modifications that will be needed to change the icon size.
To change the icon size you need to pick every icon individually and set its size. You can do this using a for loop to adjust all sizes or you can change the size of a particular icon to create your custom effect.
Below is the code segment which will help you understand the changes that need to be done and how can you pick the icons.
1 2 3 4 5 6 7 8 9 10 |
BottomNavigationView bottomNavigationView = (BottomNavigationView) configurationActivity.findViewById(R.id.bottom_navigation_view); BottomNavigationMenuView menuView = (BottomNavigationMenuView) bottomNavigationView.getChildAt(0); for (int i = 0; i < menuView.getChildCount(); i++) { final View iconView = menuView.getChildAt(i).findViewById(android.support.design.R.id.icon); final ViewGroup.LayoutParams layoutParams = iconView.getLayoutParams(); final DisplayMetrics displayMetrics = getResources().getDisplayMetrics(); layoutParams.height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 32, displayMetrics); layoutParams.width = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 32, displayMetrics); iconView.setLayoutParams(layoutParams); } |
You can set the size according to your need and it will work like a charm.
Thank you very much. This is Vedesh Kumar signing off.
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.