本文整理汇总了Java中android.support.design.internal.BottomNavigationMenuView类的典型用法代码示例。如果您正苦于以下问题:Java BottomNavigationMenuView类的具体用法?Java BottomNavigationMenuView怎么用?Java BottomNavigationMenuView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BottomNavigationMenuView类属于android.support.design.internal包,在下文中一共展示了BottomNavigationMenuView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setBottomIconOriColor
import android.support.design.internal.BottomNavigationMenuView; //导入依赖的package包/类
private void setBottomIconOriColor(BottomNavigationView bottomView) {
try {
Field mMenuViewField = BottomNavigationView.class.getDeclaredField("mMenuView");
mMenuViewField.setAccessible(true);
BottomNavigationMenuView mMenuView = (BottomNavigationMenuView) mMenuViewField.get(bottomView);
Field mButtonsField = BottomNavigationMenuView.class.getDeclaredField("mButtons");
mButtonsField.setAccessible(true);
BottomNavigationItemView[] mButtons = (BottomNavigationItemView[]) mButtonsField.get(mMenuView);
Field mIconField = BottomNavigationItemView.class.getDeclaredField("mIcon");
mIconField.setAccessible(true);
for (BottomNavigationItemView item : mButtons) {
ImageView mIcon = (ImageView) mIconField.get(item);
mIcon.setImageTintList(null);
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例2: disableShiftMode
import android.support.design.internal.BottomNavigationMenuView; //导入依赖的package包/类
public static void disableShiftMode(BottomNavigationView navigationView) {
BottomNavigationMenuView menuView = (BottomNavigationMenuView) navigationView.getChildAt(0);
try {
Field shiftMode = menuView.getClass().getDeclaredField("mShiftingMode");
shiftMode.setAccessible(true);
shiftMode.setBoolean(menuView, false);
shiftMode.setAccessible(false);
for (int i = 0; i < menuView.getChildCount(); i++) {
BottomNavigationItemView itemView = (BottomNavigationItemView) menuView.getChildAt(i);
itemView.setShiftingMode(false);
itemView.setChecked(itemView.getItemData().isChecked());
}
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
}
示例3: centerMenuIcon
import android.support.design.internal.BottomNavigationMenuView; //导入依赖的package包/类
private void centerMenuIcon() {
BottomNavigationMenuView menuView = getBottomMenuView();
if (menuView != null) {
for (int i = 0; i < menuView.getChildCount(); i++) {
BottomNavigationItemView menuItemView = (BottomNavigationItemView) menuView.getChildAt(i);
AppCompatImageView icon = (AppCompatImageView) menuItemView.getChildAt(0);
FrameLayout.LayoutParams params = (LayoutParams) icon.getLayoutParams();
params.gravity = Gravity.CENTER;
menuItemView.setShiftingMode(true);
}
}
}
示例4: enableShiftingMode
import android.support.design.internal.BottomNavigationMenuView; //导入依赖的package包/类
/**
* enable the shifting mode for navigation
*
* @param enable It will has a shift animation if true. Otherwise all items are the same width.
*/
public void enableShiftingMode(boolean enable) {
/*
1. get field in this class
private final BottomNavigationMenuView mMenuView;
2. change field mShiftingMode value in mMenuView
private boolean mShiftingMode = true;
*/
// 1. get mMenuView
BottomNavigationMenuView mMenuView = getBottomNavigationMenuView();
// 2. change field mShiftingMode value in mMenuView
setField(mMenuView.getClass(), mMenuView, "mShiftingMode", enable);
mMenuView.updateMenuView();
}
示例5: enableItemShiftingMode
import android.support.design.internal.BottomNavigationMenuView; //导入依赖的package包/类
/**
* enable the shifting mode for each item
*
* @param enable It will has a shift animation for item if true. Otherwise the item text always be shown.
*/
public void enableItemShiftingMode(boolean enable) {
/*
1. get field in this class
private final BottomNavigationMenuView mMenuView;
2. get field in this mMenuView
private BottomNavigationItemView[] mButtons;
3. change field mShiftingMode value in mButtons
private boolean mShiftingMode = true;
*/
// 1. get mMenuView
BottomNavigationMenuView mMenuView = getBottomNavigationMenuView();
// 2. get mButtons
BottomNavigationItemView[] mButtons = getBottomNavigationItemViews();
// 3. change field mShiftingMode value in mButtons
for (BottomNavigationItemView button : mButtons) {
setField(button.getClass(), button, "mShiftingMode", enable);
}
mMenuView.updateMenuView();
}
示例6: disableShiftMode
import android.support.design.internal.BottomNavigationMenuView; //导入依赖的package包/类
public static void disableShiftMode(BottomNavigationView navigationView) {
BottomNavigationMenuView menuView = (BottomNavigationMenuView) navigationView.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 itemView = (BottomNavigationItemView) menuView.getChildAt(i);
itemView.setShiftingMode(false);
itemView.setChecked(itemView.getItemData().isChecked());
}
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
}
示例7: disableShiftMode
import android.support.design.internal.BottomNavigationMenuView; //导入依赖的package包/类
/**
* 取消BottomNavigationView各item切换时的位移动效
*
* @param navigationView 底部导航栏视图
*/
public static void disableShiftMode(BottomNavigationView navigationView) {
BottomNavigationMenuView menuView = (BottomNavigationMenuView) navigationView.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 itemView = (BottomNavigationItemView) menuView.getChildAt(i);
itemView.setShiftingMode(false);
itemView.setChecked(itemView.getItemData().isChecked());
}
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
}
示例8: disableShiftingMode
import android.support.design.internal.BottomNavigationMenuView; //导入依赖的package包/类
private void disableShiftingMode() {
BottomNavigationMenuView menuView = (BottomNavigationMenuView) 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 the checked value so that the view will be updated.
item.setChecked(item.getItemData().isChecked());
}
} catch (NoSuchFieldException | IllegalAccessException e) {
// Do nothing if reflection fails.
}
}
示例9: removeMenuShiftMode
import android.support.design.internal.BottomNavigationMenuView; //导入依赖的package包/类
/**
* Remove the BottomNavigationView menu shift
*/
private void removeMenuShiftMode() {
int childCount = mBottomNavigationView.getChildCount();
for (int i = 0; i < childCount; i++) {
if (mBottomNavigationView.getChildAt(i) instanceof BottomNavigationMenuView) {
BottomNavigationMenuView bottomNavigationMenuView = (BottomNavigationMenuView) mBottomNavigationView.getChildAt(i);
try {
Field shiftingMode = bottomNavigationMenuView.getClass().getDeclaredField("mShiftingMode");
shiftingMode.setAccessible(true);
shiftingMode.setBoolean(bottomNavigationMenuView, false);
shiftingMode.setAccessible(false);
} catch (Exception e) {
Log.e(LOG_TAG, "## removeMenuShiftMode failed " + e.getMessage());
}
}
}
}
示例10: getNavigationItemTitles
import android.support.design.internal.BottomNavigationMenuView; //导入依赖的package包/类
public static List<String> getNavigationItemTitles(BottomNavigationView navigationView) {
List<String> list = new ArrayList<>();
BottomNavigationMenuView menuView = (BottomNavigationMenuView) navigationView.getChildAt(0);
for (int i = 0; i < menuView.getChildCount(); i++) {
BottomNavigationItemView itemView = (BottomNavigationItemView) menuView.getChildAt(i);
list.add((String) itemView.getItemData().getTitle());
}
return list;
}
示例11: getBottomMenuView
import android.support.design.internal.BottomNavigationMenuView; //导入依赖的package包/类
private BottomNavigationMenuView getBottomMenuView() {
Object menuView = null;
try {
Field field = BottomNavigationView.class.getDeclaredField("mMenuView");
field.setAccessible(true);
menuView = field.get(this);
} catch (Exception e) {
e.printStackTrace();
}
return (BottomNavigationMenuView) menuView;
}
示例12: setCurrentItem
import android.support.design.internal.BottomNavigationMenuView; //导入依赖的package包/类
/**
* set the current checked item
*
* @param item start from 0.
*/
public void setCurrentItem(int item) {
// check bounds
if (item < 0 || item >= getMaxItemCount()) {
throw new ArrayIndexOutOfBoundsException("item is out of bounds, we expected 0 - "
+ (getMaxItemCount() - 1) + ". Actually " + item);
}
/*
1. get field in this class
private final BottomNavigationMenuView mMenuView;
2. get field in mMenuView
private BottomNavigationItemView[] mButtons;
private final OnClickListener mOnClickListener;
3. call mOnClickListener.onClick();
*/
// 1. get mMenuView
BottomNavigationMenuView mMenuView = getBottomNavigationMenuView();
// 2. get mButtons
BottomNavigationItemView[] mButtons = getBottomNavigationItemViews();
// get mOnClickListener
OnClickListener mOnClickListener = getField(mMenuView.getClass(), mMenuView, "mOnClickListener");
// System.out.println("mMenuView:" + mMenuView + " mButtons:" + mButtons + " mOnClickListener" + mOnClickListener);
// 3. call mOnClickListener.onClick();
mOnClickListener.onClick(mButtons[item]);
}
示例13: getBottomNavigationItemViews
import android.support.design.internal.BottomNavigationMenuView; //导入依赖的package包/类
/**
* get private mButtons in mMenuView
*
* @return
*/
public BottomNavigationItemView[] getBottomNavigationItemViews() {
if (null != mButtons)
return mButtons;
/*
* 1 private final BottomNavigationMenuView mMenuView;
* 2 private BottomNavigationItemView[] mButtons;
*/
BottomNavigationMenuView mMenuView = getBottomNavigationMenuView();
mButtons = getField(mMenuView.getClass(), mMenuView, "mButtons");
return mButtons;
}
示例14: setItemHeight
import android.support.design.internal.BottomNavigationMenuView; //导入依赖的package包/类
/**
* set menu item height
*
* @param height in px
*/
public void setItemHeight(int height) {
// 1. get mMenuView
final BottomNavigationMenuView mMenuView = getBottomNavigationMenuView();
// 2. set private final int mItemHeight in mMenuView
setField(mMenuView.getClass(), mMenuView, "mItemHeight", height);
mMenuView.updateMenuView();
}
示例15: getItemHeight
import android.support.design.internal.BottomNavigationMenuView; //导入依赖的package包/类
/**
* get menu item height
*
* @return in px
*/
public int getItemHeight() {
// 1. get mMenuView
final BottomNavigationMenuView mMenuView = getBottomNavigationMenuView();
// 2. get private final int mItemHeight in mMenuView
return getField(mMenuView.getClass(), mMenuView, "mItemHeight");
}