### Using AHBottomNavigation with XML menu
Source: https://github.com/aurelhubert/ahbottomnavigation/blob/master/README.md
Alternative setup using an XML menu resource and AHBottomNavigationAdapter to populate the bottom navigation. Requires a menu resource and an array of tab colors.
```java
int[] tabColors = getApplicationContext().getResources().getIntArray(R.array.tab_colors);
AHBottomNavigation bottomNavigation = (AHBottomNavigation) findViewById(R.id.bottom_navigation);
AHBottomNavigationAdapter navigationAdapter = new AHBottomNavigationAdapter(this, R.menu.bottom_navigation_menu_3);
navigationAdapter.setupWithBottomNavigation(bottomNavigation, tabColors);
```
--------------------------------
### Java integration in Activity/Fragment
Source: https://github.com/aurelhubert/ahbottomnavigation/blob/master/README.md
Complete Java example for setting up AHBottomNavigation: creating items, adding them, configuring colors, behavior, notifications, and listeners. Includes commented options for title states and colored navigation.
```java
AHBottomNavigation bottomNavigation = (AHBottomNavigation) findViewById(R.id.bottom_navigation);
// Create items
AHBottomNavigationItem item1 = new AHBottomNavigationItem(R.string.tab_1, R.drawable.ic_maps_place, R.color.color_tab_1);
AHBottomNavigationItem item2 = new AHBottomNavigationItem(R.string.tab_2, R.drawable.ic_maps_local_bar, R.color.color_tab_2);
AHBottomNavigationItem item3 = new AHBottomNavigationItem(R.string.tab_3, R.drawable.ic_maps_local_restaurant, R.color.color_tab_3);
// Add items
bottomNavigation.addItem(item1);
bottomNavigation.addItem(item2);
bottomNavigation.addItem(item3);
// Set background color
bottomNavigation.setDefaultBackgroundColor(Color.parseColor("#FEFEFE"));
// Disable the translation inside the CoordinatorLayout
bottomNavigation.setBehaviorTranslationEnabled(false);
// Enable the translation of the FloatingActionButton
bottomNavigation.manageFloatingActionButtonBehavior(floatingActionButton);
// Change colors
bottomNavigation.setAccentColor(Color.parseColor("#F63D2B"));
bottomNavigation.setInactiveColor(Color.parseColor("#747474"));
// Force to tint the drawable (useful for font with icon for example)
bottomNavigation.setForceTint(true);
// Display color under navigation bar (API 21+)
// Don't forget these lines in your style-v21
// - true
// - true
bottomNavigation.setTranslucentNavigationEnabled(true);
// Manage titles
bottomNavigation.setTitleState(AHBottomNavigation.TitleState.SHOW_WHEN_ACTIVE);
bottomNavigation.setTitleState(AHBottomNavigation.TitleState.ALWAYS_SHOW);
bottomNavigation.setTitleState(AHBottomNavigation.TitleState.ALWAYS_HIDE);
// Use colored navigation with circle reveal effect
bottomNavigation.setColored(true);
// Set current item programmatically
bottomNavigation.setCurrentItem(1);
// Customize notification (title, background, typeface)
bottomNavigation.setNotificationBackgroundColor(Color.parseColor("#F63D2B"));
// Add or remove notification for each item
bottomNavigation.setNotification("1", 3);
// OR
AHNotification notification = new AHNotification.Builder()
.setText("1")
.setBackgroundColor(ContextCompat.getColor(DemoActivity.this, R.color.color_notification_back))
.setTextColor(ContextCompat.getColor(DemoActivity.this, R.color.color_notification_text))
.build();
bottomNavigation.setNotification(notification, 1);
// Enable / disable item & set disable color
bottomNavigation.enableItemAtPosition(2);
bottomNavigation.disableItemAtPosition(2);
bottomNavigation.setItemDisableColor(Color.parseColor("#3A000000"));
// Set listeners
bottomNavigation.setOnTabSelectedListener(new AHBottomNavigation.OnTabSelectedListener() {
@Override
public boolean onTabSelected(int position, boolean wasSelected) {
// Do something cool here...
return true;
}
});
bottomNavigation.setOnNavigationPositionListener(new AHBottomNavigation.OnNavigationPositionListener() {
@Override public void onPositionChange(int y) {
// Manage the new y position
}
});
```
--------------------------------
### XML layout with AHBottomNavigation
Source: https://github.com/aurelhubert/ahbottomnavigation/blob/master/README.md
Two layout options: a simple AHBottomNavigation view and a CoordinatorLayout wrapper for bottom placement. The second option is useful when using CoordinatorLayout.
```xml
```
```xml
...
```
--------------------------------
### Gradle dependency for AHBottomNavigation
Source: https://github.com/aurelhubert/ahbottomnavigation/blob/master/README.md
Add the AHBottomNavigation library dependency to your app's build.gradle file. Use the compile configuration as shown.
```groovy
dependencies {
compile 'com.aurelhubert:ahbottomnavigation:2.3.4'
}
```