本文整理汇总了Java中com.ashokvarma.bottomnavigation.BottomNavigationBar类的典型用法代码示例。如果您正苦于以下问题:Java BottomNavigationBar类的具体用法?Java BottomNavigationBar怎么用?Java BottomNavigationBar使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BottomNavigationBar类属于com.ashokvarma.bottomnavigation包,在下文中一共展示了BottomNavigationBar类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onLayoutChild
import com.ashokvarma.bottomnavigation.BottomNavigationBar; //导入依赖的package包/类
@Override
public boolean onLayoutChild(CoordinatorLayout parent, final V child, int layoutDirection) {
// First let the parent lay it out
parent.onLayoutChild(child, layoutDirection);
if (child instanceof BottomNavigationBar) {
mViewRef = new WeakReference<>((BottomNavigationBar) child);
}
child.post(new Runnable() {
@Override
public void run() {
mBottomNavHeight = child.getHeight();
}
});
updateSnackBarPosition(parent, child, getSnackBarInstance(parent, child));
return super.onLayoutChild(parent, child, layoutDirection);
}
示例2: getFabTranslationYForBottomNavigationBar
import com.ashokvarma.bottomnavigation.BottomNavigationBar; //导入依赖的package包/类
private float[] getFabTranslationYForBottomNavigationBar(CoordinatorLayout parent,
FloatingActionButton fab) {
float minOffset = 0;
float viewHeight = 0;
final List<View> dependencies = parent.getDependencies(fab);
for (int i = 0, z = dependencies.size(); i < z; i++) {
final View view = dependencies.get(i);
if (view instanceof BottomNavigationBar) {
viewHeight = view.getHeight();
minOffset = Math.min(minOffset,
ViewCompat.getTranslationY(view) - viewHeight);
}
}
float[] returnValues = {minOffset, viewHeight};
return returnValues;
}
示例3: initBottomNavBar
import com.ashokvarma.bottomnavigation.BottomNavigationBar; //导入依赖的package包/类
private void initBottomNavBar() {
BadgeItem badgeItem = new BadgeItem();
badgeItem.setHideOnSelect(false)
.setText("5")
.setBackgroundColorResource(R.color.colorAccent)
.setBorderWidth(0);
mBottomNavBar.setMode(BottomNavigationBar.MODE_FIXED);
mBottomNavBar.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_STATIC);
mBottomNavBar.addItem(new BottomNavigationItem(R.drawable.ic_main_meipai_normal, R.string.tab_video)).setActiveColor(R.color.colorAccent)
.addItem(new BottomNavigationItem(R.drawable.ic_main_focus_normal, R.string.tab_focus).setActiveColorResource(R.color.colorAccent))
.addItem(new BottomNavigationItem(R.drawable.ic_main_meipai_normal, "拍拍拍")).setActiveColor(R.color.colorAccent)
.addItem(new BottomNavigationItem(R.drawable.ic_main_channel_normal, R.string.tab_channel).setActiveColorResource(R.color.colorAccent))
.addItem(new BottomNavigationItem(R.drawable.ic_main_personal_normal, R.string.tab_mine).setActiveColorResource(R.color.colorAccent).setBadgeItem(badgeItem))
.setFirstSelectedPosition(0)
.initialise();
mBottomNavBar.setTabSelectedListener(this);
}
示例4: handleDirection
import com.ashokvarma.bottomnavigation.BottomNavigationBar; //导入依赖的package包/类
private void handleDirection(CoordinatorLayout parent, V child, int scrollDirection) {
BottomNavigationBar bottomNavigationBar = mViewRef.get();
if (bottomNavigationBar != null && bottomNavigationBar.isAutoHideEnabled()) {
if (scrollDirection == ScrollDirection.SCROLL_DIRECTION_DOWN && bottomNavigationBar.isHidden()) {
updateSnackBarPosition(parent, child, getSnackBarInstance(parent, child), -mBottomNavHeight);
bottomNavigationBar.show();
} else if (scrollDirection == ScrollDirection.SCROLL_DIRECTION_UP && !bottomNavigationBar.isHidden()) {
updateSnackBarPosition(parent, child, getSnackBarInstance(parent, child), 0);
bottomNavigationBar.hide();
}
}
}
示例5: initViews
import com.ashokvarma.bottomnavigation.BottomNavigationBar; //导入依赖的package包/类
@Override
protected void initViews() {
mBottomNavBar
.setMode(BottomNavigationBar.MODE_SHIFTING)
.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_RIPPLE)
.setBarBackgroundColor(R.color.main_color)
.setInActiveColor(R.color.main_color)
.setActiveColor(R.color.md_white_1000)
.addItem(new BottomNavigationItem(R.drawable.menu_news, "新闻"))
.addItem(new BottomNavigationItem(R.drawable.menu_photo, "美女"))
.addItem(new BottomNavigationItem(R.drawable.menu_movie, "电影"))
.addItem(new BottomNavigationItem(R.drawable.menu_video, "视频"))
.addItem(new BottomNavigationItem(R.drawable.menu_mine, "我的"))
.initialise();
mBottomNavBar.setTabSelectedListener(new BottomNavigationBar.SimpleOnTabSelectedListener(){
@Override
public void onTabSelected(int position) {
mCurrentItem = position;
mHandler.sendEmptyMessage(MESSAGE_SWITCH_ITEM);
}
});
mAdapter = new ViewPagerAdapter(getSupportFragmentManager());
vpContainer.setAdapter(mAdapter);
vpContainer.setOffscreenPageLimit(3);
vpContainer.setNoScroll(true);
}
示例6: initNavigation
import com.ashokvarma.bottomnavigation.BottomNavigationBar; //导入依赖的package包/类
private void initNavigation() {
mBottomNavigation.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_RIPPLE)
.setMode(BottomNavigationBar.MODE_SHIFTING)
.addItem(new BottomNavigationItem(R.drawable.ic_home, getString(R.string.nav_00_title)).setActiveColorResource(R.color.colorPrimary))
.addItem(new BottomNavigationItem(R.drawable.ic_view_headline, getString(R.string.nav_01_title)).setActiveColorResource(R.color.colorPrimary))
.addItem(new BottomNavigationItem(R.drawable.ic_live_tv, getString(R.string.nav_02_title)).setActiveColorResource(R.color.colorPrimary))
.setFirstSelectedPosition(0)
.setTabSelectedListener(this)
.initialise();
}
示例7: initBottomBar
import com.ashokvarma.bottomnavigation.BottomNavigationBar; //导入依赖的package包/类
private void initBottomBar(Bundle savedInstanceState) {
bottom_navigation_bar = (BottomNavigationBar) findViewById(R.id.bottom_navigation_bar);
bottom_navigation_bar.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_STATIC);
bottom_navigation_bar.setMode(BottomNavigationBar.MODE_CLASSIC);
bottom_navigation_bar
//setBadgeItem(numberBadgeItem)
.addItem(new BottomNavigationItem(R.drawable.bb_menu_lessons, getString(R.string.cap_bb_menu_lessons)).setActiveColorResource(R.color.flux_main_color))
.addItem(new BottomNavigationItem(R.drawable.bb_menu_scheduled, getString(R.string.cap_bb_menu_scheduled)).setActiveColorResource(R.color.flux_main_color))
.addItem(new BottomNavigationItem(R.drawable.bb_menu_discover, getString(R.string.cap_bb_menu_discover)).setActiveColorResource(R.color.flux_main_color))
.addItem(new BottomNavigationItem(R.drawable.bb_menu_me, getString(R.string.cap_bb_menu_me)).setActiveColorResource(R.color.flux_main_color))
.setFirstSelectedPosition(0)
.initialise();
}
示例8: loadData
import com.ashokvarma.bottomnavigation.BottomNavigationBar; //导入依赖的package包/类
@Override
protected void loadData() {
bottomNavigationBar.setMode(BottomNavigationBar.MODE_FIXED);
bottomNavigationBar
.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_STATIC
);
bottomNavigationBar.addItem(new BottomNavigationItem(R.drawable.ic_picture, "图片").setActiveColorResource(R.color.picture_color))
.addItem(new BottomNavigationItem(R.drawable.ic_news, "新闻").setActiveColorResource(R.color.news_color))
.addItem(new BottomNavigationItem(R.drawable.ic_my, "我的").setActiveColorResource(R.color.my_color))
.setFirstSelectedPosition(0)
.initialise();
fragments = getFragments();
setDefaultFragment();
bottomNavigationBar.setTabSelectedListener(this);
}
示例9: setUpBottomNavBar
import com.ashokvarma.bottomnavigation.BottomNavigationBar; //导入依赖的package包/类
private void setUpBottomNavBar() {
bottomNavBar = (BottomNavigationBar) findViewById(R.id.bottom_navigation);
bottomNavBar
.addItem(new BottomNavigationItem(R.drawable.ic_search_24dp, R.string.search))
.addItem(new BottomNavigationItem(R.drawable.ic_favorite_24dp, R.string.favorites))
.addItem(new BottomNavigationItem(R.drawable.ic_profile_24dp, R.string.profile))
.initialise();
bottomNavBar.setTabSelectedListener(this);
}
示例10: onCreate
import com.ashokvarma.bottomnavigation.BottomNavigationBar; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fabric.with(this, new Crashlytics());
setContentView(R.layout.activity_home);
bottomNavigationBar = (BottomNavigationBar) findViewById(R.id.bottom_navigation_bar);
fabHome = (FloatingActionButton) findViewById(R.id.fab_home);
modeSpinner = (Spinner) findViewById(R.id.mode_spinner);
bgSpinner = (Spinner) findViewById(R.id.bg_spinner);
shapeSpinner = (Spinner) findViewById(R.id.shape_spinner);
itemSpinner = (Spinner) findViewById(R.id.item_spinner);
autoHide = (CheckBox) findViewById(R.id.auto_hide);
toggleHide = (Button) findViewById(R.id.toggle_hide);
toggleBadge = (Button) findViewById(R.id.toggle_badge);
message = (TextView) findViewById(R.id.message);
fragment1 = TextFragmentKt.newTextFragmentInstance(getString(R.string.para1));
fragment2 = TextFragmentKt.newTextFragmentInstance(getString(R.string.para2));
fragment3 = TextFragmentKt.newTextFragmentInstance(getString(R.string.para3));
fragment4 = TextFragmentKt.newTextFragmentInstance(getString(R.string.para4));
fragment5 = TextFragmentKt.newTextFragmentInstance(getString(R.string.para5));
fragment6 = TextFragmentKt.newTextFragmentInstance(getString(R.string.para6));
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, Arrays.asList(new String[]{"MODE_DEFAULT", "MODE_FIXED", "MODE_SHIFTING", "MODE_FIXED_NO_TITLE", "MODE_SHIFTING_NO_TITLE"}));
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
modeSpinner.setAdapter(adapter);
modeSpinner.setSelection(2);
ArrayAdapter<String> itemAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, Arrays.asList(new String[]{"3 items", "4 items", "5 items"}));
itemAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
itemSpinner.setAdapter(itemAdapter);
itemSpinner.setSelection(2);
ArrayAdapter<String> shapeAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, Arrays.asList(new String[]{"SHAPE_OVAL", "SHAPE_RECTANGLE", "SHAPE_HEART", "SHAPE_STAR_3_VERTICES", "SHAPE_STAR_4_VERTICES", "SHAPE_STAR_5_VERTICES", "SHAPE_STAR_6_VERTICES"}));
shapeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
shapeSpinner.setAdapter(shapeAdapter);
shapeSpinner.setSelection(5);
ArrayAdapter<String> bgAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, Arrays.asList(new String[]{"BACKGROUND_STYLE_DEFAULT", "BACKGROUND_STYLE_STATIC", "BACKGROUND_STYLE_RIPPLE"}));
bgAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
bgSpinner.setAdapter(bgAdapter);
bgSpinner.setSelection(1);
modeSpinner.setOnItemSelectedListener(this);
bgSpinner.setOnItemSelectedListener(this);
shapeSpinner.setOnItemSelectedListener(this);
itemSpinner.setOnItemSelectedListener(this);
autoHide.setOnCheckedChangeListener(this);
toggleHide.setOnClickListener(this);
toggleBadge.setOnClickListener(this);
fabHome.setOnClickListener(this);
bottomNavigationBar.setTabSelectedListener(this);
}
示例11: isDependent
import com.ashokvarma.bottomnavigation.BottomNavigationBar; //导入依赖的package包/类
private boolean isDependent(View dependency) {
return dependency instanceof BottomNavigationBar || dependency instanceof Snackbar.SnackbarLayout;
}
示例12: onCreate
import com.ashokvarma.bottomnavigation.BottomNavigationBar; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
((FDroidApp) getApplication()).applyTheme(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
adapter = new MainViewAdapter(this);
pager = (RecyclerView) findViewById(R.id.main_view_pager);
pager.setHasFixedSize(true);
pager.setLayoutManager(new NonScrollingHorizontalLayoutManager(this));
pager.setAdapter(adapter);
// Without this, the focus is completely busted on pre 15 devices. Trying to use them
// without this ends up with each child view showing for a fraction of a second, then
// reverting back to the "Latest" screen again, in completely non-deterministic ways.
if (Build.VERSION.SDK_INT <= 15) {
pager.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
}
updatesBadge = new BadgeItem().hide(false);
bottomNavigation = (BottomNavigationBar) findViewById(R.id.bottom_navigation);
bottomNavigation.setTabSelectedListener(this)
.setBarBackgroundColor(getBottomNavigationBackgroundColorResId())
.setInActiveColor(R.color.bottom_nav_items)
.setActiveColor(android.R.color.white)
.setMode(BottomNavigationBar.MODE_FIXED)
.addItem(new BottomNavigationItem(R.drawable.ic_latest, R.string.main_menu__latest_apps))
.addItem(new BottomNavigationItem(R.drawable.ic_categories, R.string.main_menu__categories))
.addItem(new BottomNavigationItem(R.drawable.ic_nearby, R.string.main_menu__swap_nearby))
.addItem(new BottomNavigationItem(R.drawable.ic_updates, R.string.updates).setBadgeItem(updatesBadge))
.addItem(new BottomNavigationItem(R.drawable.ic_settings, R.string.menu_settings))
.initialise();
IntentFilter updateableAppsFilter = new IntentFilter(AppUpdateStatusManager.BROADCAST_APPSTATUS_LIST_CHANGED);
updateableAppsFilter.addAction(AppUpdateStatusManager.BROADCAST_APPSTATUS_CHANGED);
updateableAppsFilter.addAction(AppUpdateStatusManager.BROADCAST_APPSTATUS_REMOVED);
LocalBroadcastManager.getInstance(this).registerReceiver(onUpdateableAppsChanged, updateableAppsFilter);
if (savedInstanceState != null) {
selectedMenuId = savedInstanceState.getInt(STATE_SELECTED_MENU_ID, R.id.whats_new);
}
setSelectedMenuInNav();
initialRepoUpdateIfRequired();
Intent intent = getIntent();
handleSearchOrAppViewIntent(intent);
}
示例13: onCreate
import com.ashokvarma.bottomnavigation.BottomNavigationBar; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//TODO:百度统计初始化
StatService.setSessionTimeOut(30); //两次启动应用30s视为第二次启动
StatService.setLogSenderDelayed(0); //崩溃后延迟0秒发送崩溃日志
/** 代码方式添加广告,如果您使用XML配置方式添加广告,不需要以下代码 **/
// AdsMogoLayout adsMogoLayoutCode = new AdsMogoLayout(this, "253352909fb3459babbff4adc49ca4ab");
// FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
// //设置广告出现的位置(悬浮于底部)
// params.bottomMargin = 0;
// adsMogoLayoutCode.setAdsMogoListener(new AdsMogoListener() {
// @Override
// public void onInitFinish() {}
// @Override
// public void onRequestAd(String s) {}
// @Override
// public void onRealClickAd() {}
// @Override
// public void onReceiveAd(ViewGroup viewGroup, String s) {}
// @Override
// public void onFailedReceiveAd() {}
// @Override
// public void onClickAd(String s) {}
// @Override
// public boolean onCloseAd() {return false;}
// @Override
// public void onCloseMogoDialog() {}
// @Override
// public Class getCustomEvemtPlatformAdapterClass(AdsMogoCustomEventPlatformEnum adsMogoCustomEventPlatformEnum) {return null;}
// });
// params.gravity = Gravity.BOTTOM;
// addContentView(adsMogoLayoutCode,params);
/*********************** 代码添加广告结束 ************************/
BottomNavigationBar bottomNavigationBar = (BottomNavigationBar) findViewById(R.id.bottom_navigation_bar);
bottomNavigationBar.setMode(BottomNavigationBar.MODE_FIXED);
bottomNavigationBar
.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_STATIC
);
bottomNavigationBar.addItem(new BottomNavigationItem(R.mipmap.ic_home_white_24dp, R.string.newMovie).setActiveColorResource(R.color.orange))
.addItem(new BottomNavigationItem(R.mipmap.ic_find_replace_white_24dp, R.string.search).setActiveColorResource(R.color.teal))
.addItem(new BottomNavigationItem(R.mipmap.ic_setting, R.string.setting).setActiveColorResource(R.color.blue))
.setFirstSelectedPosition(0)
.initialise();
fragments = getFragments();
setDefaultFragment();
bottomNavigationBar.setTabSelectedListener(this);
}
示例14: onCreate
import com.ashokvarma.bottomnavigation.BottomNavigationBar; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fresco.initialize(this);
setContentView(R.layout.activity_main);
mToolBar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolBar);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, mToolBar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
mFgTransaction = getSupportFragmentManager().beginTransaction();
mBottomNavigationBar = (BottomNavigationBar) findViewById(R.id.bottom_navigation_bar);
mBottomNavigationBar.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_RIPPLE);
mBottomNavigationBar
.setActiveColor(R.color.colorPrimary)
.setInActiveColor("#FFFFFF")
.setBarBackgroundColor("#ECECEC");
mBottomNavigationBar
.addItem(new BottomNavigationItem(R.drawable.ic_home_white_24dp, "Home"))
.addItem(new BottomNavigationItem(R.drawable.ic_tag_faces_white_24dp, "福利")).setActiveColor("#03A9F4")
.addItem(new BottomNavigationItem(R.drawable.ic_android_white_24dp, "Android").setActiveColor("#00BCD4"))
.addItem(new BottomNavigationItem(R.drawable.ic_phone_iphone_white_24dp, "iOS").setActiveColor("#009688"))
// .addItem(new BottomNavigationItem(R.drawable.ic_android_white_24dp, "Games").setActiveColor("#3f51b5"))
.initialise();
mBottomNavigationBar.setTabSelectedListener(mOnTabSelectedListener);
if (savedInstanceState == null) {
mHomeFragment = new GankFragment();
Bundle args = new Bundle();
args.putString("type", "all");
mHomeFragment.setArguments(args);
mFgTransaction.add(R.id.root, mHomeFragment);
// mFgTransaction.addToBackStack(null);
mFgTransaction.commit();
}
}