MD面包屑导航条 - BreadcrumbsView

2017-07-18      208      Android
项目简介

BreadcrumbsView

Material Design Breadcrumbs Navigation Widget on Android (SDK 19+, Maybe can be lower)

How to use

Import (Gradle)

First, add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Add the dependency to your app modules:

dependencies {
    compile 'moe.feng:BreadcrumbsView:latest-version'
}

XML

Place aBreadcrumbsViewto where you want in your layout xml.

For example:

<android.support.design.widget.AppBarLayout...>

	<android.support.v7.widget.Toolbar.../>

	<moe.feng.common.view.breadcrumbs.BreadcrumbsView
		android:id="@+id/breadcrumbs_view"
		android:layout_width="match_parent"
		android:layout_height="?attr/actionBarSize"
		app:popupTheme="@style/AppTheme.PopupOverlay"/>

</android.support.design.widget.AppBarLayout>

Add/RemoveBreadcrumbItem

When your interface navigates to next step, create a newBreadcrumbItemand add it toBreadcrumbsView.

UseremoveItemAfter(int)orremoveLastItemto remove items or last item.

Listen events

You can set a callback forBreadcrumbsViewto receive item click/changed events.

To simplify events, I recommend to useDefaultBreadcrumbsCallback:

new DefaultBreadcrumbsCallback() {
	@Override
	public void onNavigateBack(BreadcrumbItem item, int position) {
		// ...
	}

	@Override
	public void onNavigateNewLocation(BreadcrumbItem newItem, int changedPosition) {
		// ...
	}
}