Giter Club home page Giter Club logo

bottomnavigationview_demo's Introduction

BottomNavigationView Demo

A simple android demo that demonstrates how to implement BottomNavigationView in Kotlin

Key Points

  • app:itemBackground — The background color to be used for the bottom navigation menu
  • app:itemIconTint — The tint to be used for the icons in the bottom navigation menu
  • app:itemTextColor — The color to be used for the text in the bottom navigation menu
  • app:menu — The menu resource to be used to display items in the bottom navigation menu

Demo

Home Page

Code setup

  implementation 'com.google.android.material:material:1.2.0-alpha02'
<com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bNavigationView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/holo_blue_dark"
        app:itemIconTint="@drawable/nav_icon_color"
        app:itemTextColor="@android:color/white"
        app:menu="@menu/bottom_navigation_menu" />
<menu xmlns:android="http://schemas.android.com/apk/res/android">

    <item
        android:id="@+id/navigation_home"
        android:icon="@drawable/home_icon"
        android:title="Home" />

    <item
        android:id="@+id/navigation_history"
        android:icon="@drawable/history_icon"
        android:title="History" />

    <item
        android:id="@+id/navigation_my_account"
        android:icon="@drawable/my_account"
        android:title="My Account" />

</menu>
bNavigationView.setOnNavigationItemSelectedListener { item ->
            when (item.itemId) {
                R.id.navigation_home -> {
                    attachFragment(FirstFragment())
                    return@setOnNavigationItemSelectedListener true
                }
                R.id.navigation_history -> {
                    attachFragment(SecondFragment())
                    return@setOnNavigationItemSelectedListener true
                }
                R.id.navigation_my_account -> {
                    attachFragment(ThirdFragment())
                    return@setOnNavigationItemSelectedListener true
                }
            }
            false
        }

bottomnavigationview_demo's People

Contributors

dilip786 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.