use of android.support.design.internal.BottomNavigationMenuView in project Devsfolio by Madonahs.
the class BottomNavigationViewHelper method disableShiftMode.
@SuppressLint("RestrictedApi")
public static 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);
// noinspection RestrictedApi
item.setShiftingMode(false);
// set once again checked value, so view will be updated
// noinspection RestrictedApi
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);
}
}
use of android.support.design.internal.BottomNavigationMenuView in project Palm300Heroes by nicolite.
the class BottomNavigationViewHelper method disableShiftMode.
/**
* 去除当BottomNavigationView的item大于三个时的动画
* @param view
*/
public static 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);
// noinspection RestrictedApi
item.setShiftingMode(false);
// set once again checked value, so ui will be updated
// noinspection RestrictedApi
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);
}
}
use of android.support.design.internal.BottomNavigationMenuView in project weiui by kuaifan.
the class BottomNavigationViewEx method addAnimationListener.
private void addAnimationListener() {
/**
* 1. BottomNavigationMenuView mMenuView
* 2. private final BottomNavigationAnimationHelperBase mAnimationHelper;
* 3. private final TransitionSet mSet;
*/
BottomNavigationMenuView mMenuView = getBottomNavigationMenuView();
Object mAnimationHelper = getField(mMenuView.getClass(), mMenuView, "mAnimationHelper");
TransitionSet mSet = getField(mAnimationHelper.getClass(), mAnimationHelper, "mSet");
mSet.addListener(new Transition.TransitionListener() {
@Override
public void onTransitionStart(@NonNull Transition transition) {
}
@Override
public void onTransitionEnd(@NonNull Transition transition) {
refreshTextViewVisibility();
}
@Override
public void onTransitionCancel(@NonNull Transition transition) {
refreshTextViewVisibility();
}
@Override
public void onTransitionPause(@NonNull Transition transition) {
}
@Override
public void onTransitionResume(@NonNull Transition transition) {
}
});
}
use of android.support.design.internal.BottomNavigationMenuView in project weiui by kuaifan.
the class BottomNavigationViewEx method setIconVisibility.
/**
* change the visibility of icon
*
* @param visibility
*/
public void setIconVisibility(boolean visibility) {
/*
1. get field in this class
private final BottomNavigationMenuView mMenuView;
2. get field in mButtons
private BottomNavigationItemView[] mButtons;
3. get mIcon in mButtons
private ImageView mIcon
4. set mIcon visibility gone
5. change mItemHeight to only text size in mMenuView
*/
// 1. get mMenuView
final BottomNavigationMenuView mMenuView = getBottomNavigationMenuView();
// 2. get mButtons
BottomNavigationItemView[] mButtons = getBottomNavigationItemViews();
// 3. get mIcon in mButtons
for (BottomNavigationItemView button : mButtons) {
ImageView mIcon = getField(button.getClass(), button, "mIcon");
// 4. set mIcon visibility gone
mIcon.setVisibility(visibility ? View.VISIBLE : View.INVISIBLE);
}
// 5. change mItemHeight to only text size in mMenuView
if (!visibility) {
// if not record mItemHeight
if (!visibilityHeightRecord) {
visibilityHeightRecord = true;
mItemHeight = getItemHeight();
}
// change mItemHeight
BottomNavigationItemView button = mButtons[0];
if (null != button) {
final ImageView mIcon = getField(button.getClass(), button, "mIcon");
// System.out.println("mIcon.getMeasuredHeight():" + mIcon.getMeasuredHeight());
if (null != mIcon) {
mIcon.post(new Runnable() {
@Override
public void run() {
// System.out.println("mIcon.getMeasuredHeight():" + mIcon.getMeasuredHeight());
setItemHeight(mItemHeight - mIcon.getMeasuredHeight());
}
});
}
}
} else {
// if not record the mItemHeight, we need do nothing.
if (!visibilityHeightRecord)
return;
// restore it
setItemHeight(mItemHeight);
}
mMenuView.updateMenuView();
}
use of android.support.design.internal.BottomNavigationMenuView in project Osmand by osmandapp.
the class BottomNavigationViewHelper method disableShiftMode.
public static 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);
// noinspection RestrictedApi
item.setShiftingMode(false);
// set once again checked value, so view will be updated
// noinspection RestrictedApi
item.setChecked(item.getItemData().isChecked());
}
} catch (NoSuchFieldException e) {
Log.e(TAG, "Unable to get shift mode field", e);
} catch (IllegalAccessException e) {
Log.e(TAG, "Unable to change value of shift mode", e);
}
}
Aggregations