当前位置: 首页>>代码示例>>Java>>正文


Java BottomNavigationMenuView类代码示例

本文整理汇总了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();
    }
}
 
开发者ID:iAcn,项目名称:MBEStyle,代码行数:23,代码来源:MainActivity.java

示例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();
    }
}
 
开发者ID:InnoFang,项目名称:Android-Code-Demos,代码行数:20,代码来源:BottomNavigationViewHelper.java

示例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);
        }
    }
}
 
开发者ID:JonathandelaSen,项目名称:TheMovies,代码行数:17,代码来源:MyBottomNavigationView.java

示例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();
}
 
开发者ID:wheat7,项目名称:Cashew,代码行数:21,代码来源:BottomNavigationViewEx.java

示例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();
}
 
开发者ID:wheat7,项目名称:Cashew,代码行数:27,代码来源:BottomNavigationViewEx.java

示例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();
        }
    }
 
开发者ID:miguoer,项目名称:ApplicationCollention,代码行数:20,代码来源:BottomNavigationViewHelper.java

示例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();
    }
}
 
开发者ID:Implementist,项目名称:iReading,代码行数:25,代码来源:CommonUtils.java

示例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.
    }
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:18,代码来源:BottomSheetContentController.java

示例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());
            }
        }
    }
}
 
开发者ID:vector-im,项目名称:riot-android,代码行数:23,代码来源:VectorHomeActivity.java

示例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;
}
 
开发者ID:InnoFang,项目名称:Android-Code-Demos,代码行数:10,代码来源:BottomNavigationViewHelper.java

示例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;
}
 
开发者ID:JonathandelaSen,项目名称:TheMovies,代码行数:13,代码来源:MyBottomNavigationView.java

示例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]);

    }
 
开发者ID:wheat7,项目名称:Cashew,代码行数:35,代码来源:BottomNavigationViewEx.java

示例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;
}
 
开发者ID:wheat7,项目名称:Cashew,代码行数:17,代码来源:BottomNavigationViewEx.java

示例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();
}
 
开发者ID:wheat7,项目名称:Cashew,代码行数:14,代码来源:BottomNavigationViewEx.java

示例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");
}
 
开发者ID:wheat7,项目名称:Cashew,代码行数:12,代码来源:BottomNavigationViewEx.java


注:本文中的android.support.design.internal.BottomNavigationMenuView类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。