Reputation: 2993
As support lib ver 25 released, google produced new BottomNavigationView
as new API:
android.support.design.widget.BottomNavigationView class implements the bottom navigation pattern from the Material Design spec.
Sadly, this doesn't seem true and there is no real documentation. Apparently, the BottomNavigationView
:
xmlns:design="http://schema.android.com/apk/res/android.support.design"
How can I implement this in the project? And also how to style it to make it actually implement the Bottom Navigation pattern?
Upvotes: 3
Views: 5411
Reputation: 685
It's late reply but below solution will save someone's time.please check below points as well.
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-vector-drawable:25.3.1'
Upvotes: 1
Reputation: 63
Add to your activity
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
...>
...
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:menu="@menu/my_navigation_items" />
...
</FrameLayout>
describe menu:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/add"
android:icon="@android:drawable/ic_menu_add"
android:title="add" />
<item
android:id="@+id/delete"
android:icon="@android:drawable/ic_menu_delete"
android:title="delete" />
<item
android:id="@+id/call"
android:icon="@android:drawable/ic_menu_call"
android:title="call" />
</menu>
and then you can set listeners:
bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
// ...
return true;
}
});
You can get more information here: https://developer.android.com/reference/android/support/design/widget/BottomNavigationView.html
Upvotes: 5