android studio bottom console bar width code example
Example 1: bottom navigation bar not filling the width of the screen
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
....
if (mShiftingMode) {
final int inactiveCount = count - 1;
final int activeMaxAvailable = width - inactiveCount * mInactiveItemMinWidth;
final int activeWidth = Math.min(activeMaxAvailable, mActiveItemMaxWidth);
final int inactiveMaxAvailable = (width - activeWidth) / inactiveCount;
final int inactiveWidth = Math.min(inactiveMaxAvailable, mInactiveItemMaxWidth);
...
} else {
final int maxAvailable = width / count;
final int childWidth = Math.min(maxAvailable, mActiveItemMaxWidth);
.....
}
....
}
Example 2: bottom navigation bar not filling the width of the screen
public BottomNavigationMenuView(Context context, AttributeSet attrs) {
super(context, attrs);
...
mInactiveItemMaxWidth = res.getDimensionPixelSize(
R.dimen.design_bottom_navigation_item_max_width);
....
mActiveItemMaxWidth = res.getDimensionPixelSize(
R.dimen.design_bottom_navigation_active_item_max_width);
.....
}