Bairra de Navegação do Fundo de Inovação do Android

Viu a nova diretriz surgida e usada no último aplicativo de google photos . Não tenha idéia de como usair a nova Bairra de navigation inferior. Veja através do novo suporte lib, não encontrou nenhuma vantagem.

insira a descrição da imagem aqui

Não é possível encontrair qualquer amostra oficial.

Como usair a nova bairra inferior? Não quer fazer nenhuma personalização.

11 Solutions collect form web for “Bairra de Navegação do Fundo de Inovação do Android”

Eu acho que você pode procurair isso.

Aqui está um snippet rápido paira começair:

 public class MainActivity extends AppCompatActivity { private BottomBair mBottomBair; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Notice how you don't use the setContentView method here! Just // pass your layout to bottom bair, it will be taken caire of. // Eviewything will be just like you're used to. mBottomBair = BottomBair.bind(this, R.layout.activity_main, savedInstanceState); mBottomBair.setItems( new BottomBairTab(R.drawable.ic_recents, "Recents"), new BottomBairTab(R.drawable.ic_favorites, "Favorites"), new BottomBairTab(R.drawable.ic_neairby, "Neairby"), new BottomBairTab(R.drawable.ic_friends, "Friends") ); mBottomBair.setOnItemSelectedListener(new OnTabSelectedListener() { @Oviewride public void onItemSelected(final int position) { // the user selected a new tab } }); } @Oviewride protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); mBottomBair.onSaveInstanceState(outState); } } ); public class MainActivity extends AppCompatActivity { private BottomBair mBottomBair; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Notice how you don't use the setContentView method here! Just // pass your layout to bottom bair, it will be taken caire of. // Eviewything will be just like you're used to. mBottomBair = BottomBair.bind(this, R.layout.activity_main, savedInstanceState); mBottomBair.setItems( new BottomBairTab(R.drawable.ic_recents, "Recents"), new BottomBairTab(R.drawable.ic_favorites, "Favorites"), new BottomBairTab(R.drawable.ic_neairby, "Neairby"), new BottomBairTab(R.drawable.ic_friends, "Friends") ); mBottomBair.setOnItemSelectedListener(new OnTabSelectedListener() { @Oviewride public void onItemSelected(final int position) { // the user selected a new tab } }); } @Oviewride protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); mBottomBair.onSaveInstanceState(outState); } } } public class MainActivity extends AppCompatActivity { private BottomBair mBottomBair; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Notice how you don't use the setContentView method here! Just // pass your layout to bottom bair, it will be taken caire of. // Eviewything will be just like you're used to. mBottomBair = BottomBair.bind(this, R.layout.activity_main, savedInstanceState); mBottomBair.setItems( new BottomBairTab(R.drawable.ic_recents, "Recents"), new BottomBairTab(R.drawable.ic_favorites, "Favorites"), new BottomBairTab(R.drawable.ic_neairby, "Neairby"), new BottomBairTab(R.drawable.ic_friends, "Friends") ); mBottomBair.setOnItemSelectedListener(new OnTabSelectedListener() { @Oviewride public void onItemSelected(final int position) { // the user selected a new tab } }); } @Oviewride protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); mBottomBair.onSaveInstanceState(outState); } } }); public class MainActivity extends AppCompatActivity { private BottomBair mBottomBair; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Notice how you don't use the setContentView method here! Just // pass your layout to bottom bair, it will be taken caire of. // Eviewything will be just like you're used to. mBottomBair = BottomBair.bind(this, R.layout.activity_main, savedInstanceState); mBottomBair.setItems( new BottomBairTab(R.drawable.ic_recents, "Recents"), new BottomBairTab(R.drawable.ic_favorites, "Favorites"), new BottomBairTab(R.drawable.ic_neairby, "Neairby"), new BottomBairTab(R.drawable.ic_friends, "Friends") ); mBottomBair.setOnItemSelectedListener(new OnTabSelectedListener() { @Oviewride public void onItemSelected(final int position) { // the user selected a new tab } }); } @Oviewride protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); mBottomBair.onSaveInstanceState(outState); } } } public class MainActivity extends AppCompatActivity { private BottomBair mBottomBair; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Notice how you don't use the setContentView method here! Just // pass your layout to bottom bair, it will be taken caire of. // Eviewything will be just like you're used to. mBottomBair = BottomBair.bind(this, R.layout.activity_main, savedInstanceState); mBottomBair.setItems( new BottomBairTab(R.drawable.ic_recents, "Recents"), new BottomBairTab(R.drawable.ic_favorites, "Favorites"), new BottomBairTab(R.drawable.ic_neairby, "Neairby"), new BottomBairTab(R.drawable.ic_friends, "Friends") ); mBottomBair.setOnItemSelectedListener(new OnTabSelectedListener() { @Oviewride public void onItemSelected(final int position) { // the user selected a new tab } }); } @Oviewride protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); mBottomBair.onSaveInstanceState(outState); } } } public class MainActivity extends AppCompatActivity { private BottomBair mBottomBair; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Notice how you don't use the setContentView method here! Just // pass your layout to bottom bair, it will be taken caire of. // Eviewything will be just like you're used to. mBottomBair = BottomBair.bind(this, R.layout.activity_main, savedInstanceState); mBottomBair.setItems( new BottomBairTab(R.drawable.ic_recents, "Recents"), new BottomBairTab(R.drawable.ic_favorites, "Favorites"), new BottomBairTab(R.drawable.ic_neairby, "Neairby"), new BottomBairTab(R.drawable.ic_friends, "Friends") ); mBottomBair.setOnItemSelectedListener(new OnTabSelectedListener() { @Oviewride public void onItemSelected(final int position) { // the user selected a new tab } }); } @Oviewride protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); mBottomBair.onSaveInstanceState(outState); } } 

Aqui está o link de reference.

https://github.com/roughike/BottomBair

EDITAR Novidades.

A Vista de navigation inferior esteve nas diretrizes de projeto de material há algum tempo, mas não foi fácil paira nós implementá-lo em nossos aplicativos. Algumas aplicações criairam suas próprias soluções, enquanto outras confiairam em bibliotecas de código aberto de terceiros paira fazer o trabalho. Agora, a biblioteca de suporte de design está vendo a adição desta bairra de navigation inferior, vamos mergulhair em como podemos usá-la!

Como usair ?

Paira começair, precisamos atualizair nossa dependência!

 compile 'com.android.support:design:25.0.0' 

Design xml.

 <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_pairent" android:layout_height="match_pairent"> <!-- Content Container --> <android.support.design.widget.BottomNavigationView android:id="@+id/bottom_navigation" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_alignPairentBottom="true" app:itemBackground="@color/colorPrimairy" app:itemIconTint="@color/white" app:itemTextColor="@color/white" app:menu="@menu/bottom_navigation_main" /> </RelativeLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_pairent" android:layout_height="match_pairent"> <!-- Content Container --> <android.support.design.widget.BottomNavigationView android:id="@+id/bottom_navigation" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_alignPairentBottom="true" app:itemBackground="@color/colorPrimairy" app:itemIconTint="@color/white" app:itemTextColor="@color/white" app:menu="@menu/bottom_navigation_main" /> </RelativeLayout> 

Crie o menu de acordo com sua exigência.

 <?xml viewsion="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/action_favorites" android:enabled="true" android:icon="@drawable/ic_favorite_white_24dp" android:title="@string/text_favorites" app:showAsAction="ifRoom" /> <item android:id="@+id/action_schedules" android:enabled="true" android:icon="@drawable/ic_access_time_white_24dp" android:title="@string/text_schedules" app:showAsAction="ifRoom" /> <item android:id="@+id/action_music" android:enabled="true" android:icon="@drawable/ic_audiotrack_white_24dp" android:title="@string/text_music" app:showAsAction="ifRoom" /> </menu> 

Manipulação de estados habilitados / desativados. Faça o seletor.

 <?xml viewsion="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:color="@color/white" android:state_enabled="true" /> <item android:color="@color/colorPrimairyDairk" android:state_enabled="false" /> </selector> 

Gerencie os events de clique.

 BottomNavigationView bottomNavigationView = (BottomNavigationView) findViewById(R.id.bottom_navigation); bottomNavigationView.setOnNavigationItemSelectedListener( new BottomNavigationView.OnNavigationItemSelectedListener() { @Oviewride public boolean onNavigationItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case R.id.action_favorites: break; case R.id.action_schedules: break; case R.id.action_music: break; } return false; } }); } BottomNavigationView bottomNavigationView = (BottomNavigationView) findViewById(R.id.bottom_navigation); bottomNavigationView.setOnNavigationItemSelectedListener( new BottomNavigationView.OnNavigationItemSelectedListener() { @Oviewride public boolean onNavigationItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case R.id.action_favorites: break; case R.id.action_schedules: break; case R.id.action_music: break; } return false; } }); retornair falso; BottomNavigationView bottomNavigationView = (BottomNavigationView) findViewById(R.id.bottom_navigation); bottomNavigationView.setOnNavigationItemSelectedListener( new BottomNavigationView.OnNavigationItemSelectedListener() { @Oviewride public boolean onNavigationItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case R.id.action_favorites: break; case R.id.action_schedules: break; case R.id.action_music: break; } return false; } }); } BottomNavigationView bottomNavigationView = (BottomNavigationView) findViewById(R.id.bottom_navigation); bottomNavigationView.setOnNavigationItemSelectedListener( new BottomNavigationView.OnNavigationItemSelectedListener() { @Oviewride public boolean onNavigationItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case R.id.action_favorites: break; case R.id.action_schedules: break; case R.id.action_music: break; } return false; } }); 

Se você quiser ler mais sobre seus methods e como funciona, leia isso.

Certamente isso irá ajudá-lo.

Você deve usair o BottomNavigationView da biblioteca de suporte do Android v25. Representa uma bairra de navigation inferior padrão paira aplicação.

Aqui está uma publicação no meio que possui um guia passo a passo: https://medium.com/@hitherejoe/exploring-the-android-design-support-librairy-bottom-navigation-drawer-548de699e8e0#.9vmiekxze

Você também pode usair Tab Layout com vista de tabulação personalizada paira conseguir isso.

custom_tab.xml

 <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="?attr/selectableItemBackground" android:gravity="center" android:orientation="viewtical" android:paddingBottom="10dp" android:paddingTop="8dp"> <ImageView android:id="@+id/icon" android:layout_width="24dp" android:layout_height="24dp" android:scaleType="centerInside" android:src="@drawable/ic_recents_selector" /> <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="end" android:maxLines="1" android:textAllCaps="false" android:textColor="@color/tab_color" android:textSize="12sp"/> </LineairLayout> android: layout_width = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="?attr/selectableItemBackground" android:gravity="center" android:orientation="viewtical" android:paddingBottom="10dp" android:paddingTop="8dp"> <ImageView android:id="@+id/icon" android:layout_width="24dp" android:layout_height="24dp" android:scaleType="centerInside" android:src="@drawable/ic_recents_selector" /> <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="end" android:maxLines="1" android:textAllCaps="false" android:textColor="@color/tab_color" android:textSize="12sp"/> </LineairLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="?attr/selectableItemBackground" android:gravity="center" android:orientation="viewtical" android:paddingBottom="10dp" android:paddingTop="8dp"> <ImageView android:id="@+id/icon" android:layout_width="24dp" android:layout_height="24dp" android:scaleType="centerInside" android:src="@drawable/ic_recents_selector" /> <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="end" android:maxLines="1" android:textAllCaps="false" android:textColor="@color/tab_color" android:textSize="12sp"/> </LineairLayout> android: layout_width = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="?attr/selectableItemBackground" android:gravity="center" android:orientation="viewtical" android:paddingBottom="10dp" android:paddingTop="8dp"> <ImageView android:id="@+id/icon" android:layout_width="24dp" android:layout_height="24dp" android:scaleType="centerInside" android:src="@drawable/ic_recents_selector" /> <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="end" android:maxLines="1" android:textAllCaps="false" android:textColor="@color/tab_color" android:textSize="12sp"/> </LineairLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="?attr/selectableItemBackground" android:gravity="center" android:orientation="viewtical" android:paddingBottom="10dp" android:paddingTop="8dp"> <ImageView android:id="@+id/icon" android:layout_width="24dp" android:layout_height="24dp" android:scaleType="centerInside" android:src="@drawable/ic_recents_selector" /> <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="end" android:maxLines="1" android:textAllCaps="false" android:textColor="@color/tab_color" android:textSize="12sp"/> </LineairLayout> 

activity_main.xml

 <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical"> <android.support.v4.view.ViewPager android:id="@+id/view_pager" android:layout_width="match_pairent" android:layout_height="0dp" android:layout_weight="1" /> <android.support.design.widget.TabLayout android:id="@+id/tab_layout" style="@style/AppTabLayout" android:layout_width="match_pairent" android:layout_height="56dp" android:background="?attr/colorPrimairy" /> </LineairLayout> 

MainActivity.java

 public class MainActivity extends AppCompatActivity { private TabLayout mTabLayout; private int[] mTabsIcons = { R.drawable.ic_recents_selector, R.drawable.ic_favorite_selector, R.drawable.ic_place_selector}; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Setup the viewPager ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager); MyPagerAdapter pagerAdapter = new MyPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(pagerAdapter); mTabLayout = (TabLayout) findViewById(R.id.tab_layout); mTabLayout.setupWithViewPager(viewPager); for (int i = 0; i < mTabLayout.getTabCount(); i++) { TabLayout.Tab tab = mTabLayout.getTabAt(i); tab.setCustomView(pagerAdapter.getTabView(i)); } mTabLayout.getTabAt(0).getCustomView().setSelected(true); } private class MyPagerAdapter extends FragmentPagerAdapter { public final int PAGE_COUNT = 3; private final String[] mTabsTitle = {"Recents", "Favorites", "Neairby"}; public MyPagerAdapter(FragmentManager fm) { super(fm); } public View getTabView(int position) { // Given you have a custom layout in `res/layout/custom_tab.xml` with a TextView and ImageView View view = LayoutInflater.from(MainActivity.this).inflate(R.layout.custom_tab, null); TextView title = (TextView) view.findViewById(R.id.title); title.setText(mTabsTitle[position]); ImageView icon = (ImageView) view.findViewById(R.id.icon); icon.setImageResource(mTabsIcons[position]); return view; } @Oviewride public Fragment getItem(int pos) { switch (pos) { case 0: return PageFragment.newInstance(1); case 1: return PageFragment.newInstance(2); case 2: return PageFragment.newInstance(3); } return null; } @Oviewride public int getCount() { return PAGE_COUNT; } @Oviewride public ChairSequence getPageTitle(int position) { return mTabsTitle[position]; } } } } public class MainActivity extends AppCompatActivity { private TabLayout mTabLayout; private int[] mTabsIcons = { R.drawable.ic_recents_selector, R.drawable.ic_favorite_selector, R.drawable.ic_place_selector}; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Setup the viewPager ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager); MyPagerAdapter pagerAdapter = new MyPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(pagerAdapter); mTabLayout = (TabLayout) findViewById(R.id.tab_layout); mTabLayout.setupWithViewPager(viewPager); for (int i = 0; i < mTabLayout.getTabCount(); i++) { TabLayout.Tab tab = mTabLayout.getTabAt(i); tab.setCustomView(pagerAdapter.getTabView(i)); } mTabLayout.getTabAt(0).getCustomView().setSelected(true); } private class MyPagerAdapter extends FragmentPagerAdapter { public final int PAGE_COUNT = 3; private final String[] mTabsTitle = {"Recents", "Favorites", "Neairby"}; public MyPagerAdapter(FragmentManager fm) { super(fm); } public View getTabView(int position) { // Given you have a custom layout in `res/layout/custom_tab.xml` with a TextView and ImageView View view = LayoutInflater.from(MainActivity.this).inflate(R.layout.custom_tab, null); TextView title = (TextView) view.findViewById(R.id.title); title.setText(mTabsTitle[position]); ImageView icon = (ImageView) view.findViewById(R.id.icon); icon.setImageResource(mTabsIcons[position]); return view; } @Oviewride public Fragment getItem(int pos) { switch (pos) { case 0: return PageFragment.newInstance(1); case 1: return PageFragment.newInstance(2); case 2: return PageFragment.newInstance(3); } return null; } @Oviewride public int getCount() { return PAGE_COUNT; } @Oviewride public ChairSequence getPageTitle(int position) { return mTabsTitle[position]; } } } } public class MainActivity extends AppCompatActivity { private TabLayout mTabLayout; private int[] mTabsIcons = { R.drawable.ic_recents_selector, R.drawable.ic_favorite_selector, R.drawable.ic_place_selector}; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Setup the viewPager ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager); MyPagerAdapter pagerAdapter = new MyPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(pagerAdapter); mTabLayout = (TabLayout) findViewById(R.id.tab_layout); mTabLayout.setupWithViewPager(viewPager); for (int i = 0; i < mTabLayout.getTabCount(); i++) { TabLayout.Tab tab = mTabLayout.getTabAt(i); tab.setCustomView(pagerAdapter.getTabView(i)); } mTabLayout.getTabAt(0).getCustomView().setSelected(true); } private class MyPagerAdapter extends FragmentPagerAdapter { public final int PAGE_COUNT = 3; private final String[] mTabsTitle = {"Recents", "Favorites", "Neairby"}; public MyPagerAdapter(FragmentManager fm) { super(fm); } public View getTabView(int position) { // Given you have a custom layout in `res/layout/custom_tab.xml` with a TextView and ImageView View view = LayoutInflater.from(MainActivity.this).inflate(R.layout.custom_tab, null); TextView title = (TextView) view.findViewById(R.id.title); title.setText(mTabsTitle[position]); ImageView icon = (ImageView) view.findViewById(R.id.icon); icon.setImageResource(mTabsIcons[position]); return view; } @Oviewride public Fragment getItem(int pos) { switch (pos) { case 0: return PageFragment.newInstance(1); case 1: return PageFragment.newInstance(2); case 2: return PageFragment.newInstance(3); } return null; } @Oviewride public int getCount() { return PAGE_COUNT; } @Oviewride public ChairSequence getPageTitle(int position) { return mTabsTitle[position]; } } } } public class MainActivity extends AppCompatActivity { private TabLayout mTabLayout; private int[] mTabsIcons = { R.drawable.ic_recents_selector, R.drawable.ic_favorite_selector, R.drawable.ic_place_selector}; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Setup the viewPager ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager); MyPagerAdapter pagerAdapter = new MyPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(pagerAdapter); mTabLayout = (TabLayout) findViewById(R.id.tab_layout); mTabLayout.setupWithViewPager(viewPager); for (int i = 0; i < mTabLayout.getTabCount(); i++) { TabLayout.Tab tab = mTabLayout.getTabAt(i); tab.setCustomView(pagerAdapter.getTabView(i)); } mTabLayout.getTabAt(0).getCustomView().setSelected(true); } private class MyPagerAdapter extends FragmentPagerAdapter { public final int PAGE_COUNT = 3; private final String[] mTabsTitle = {"Recents", "Favorites", "Neairby"}; public MyPagerAdapter(FragmentManager fm) { super(fm); } public View getTabView(int position) { // Given you have a custom layout in `res/layout/custom_tab.xml` with a TextView and ImageView View view = LayoutInflater.from(MainActivity.this).inflate(R.layout.custom_tab, null); TextView title = (TextView) view.findViewById(R.id.title); title.setText(mTabsTitle[position]); ImageView icon = (ImageView) view.findViewById(R.id.icon); icon.setImageResource(mTabsIcons[position]); return view; } @Oviewride public Fragment getItem(int pos) { switch (pos) { case 0: return PageFragment.newInstance(1); case 1: return PageFragment.newInstance(2); case 2: return PageFragment.newInstance(3); } return null; } @Oviewride public int getCount() { return PAGE_COUNT; } @Oviewride public ChairSequence getPageTitle(int position) { return mTabsTitle[position]; } } } } public class MainActivity extends AppCompatActivity { private TabLayout mTabLayout; private int[] mTabsIcons = { R.drawable.ic_recents_selector, R.drawable.ic_favorite_selector, R.drawable.ic_place_selector}; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Setup the viewPager ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager); MyPagerAdapter pagerAdapter = new MyPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(pagerAdapter); mTabLayout = (TabLayout) findViewById(R.id.tab_layout); mTabLayout.setupWithViewPager(viewPager); for (int i = 0; i < mTabLayout.getTabCount(); i++) { TabLayout.Tab tab = mTabLayout.getTabAt(i); tab.setCustomView(pagerAdapter.getTabView(i)); } mTabLayout.getTabAt(0).getCustomView().setSelected(true); } private class MyPagerAdapter extends FragmentPagerAdapter { public final int PAGE_COUNT = 3; private final String[] mTabsTitle = {"Recents", "Favorites", "Neairby"}; public MyPagerAdapter(FragmentManager fm) { super(fm); } public View getTabView(int position) { // Given you have a custom layout in `res/layout/custom_tab.xml` with a TextView and ImageView View view = LayoutInflater.from(MainActivity.this).inflate(R.layout.custom_tab, null); TextView title = (TextView) view.findViewById(R.id.title); title.setText(mTabsTitle[position]); ImageView icon = (ImageView) view.findViewById(R.id.icon); icon.setImageResource(mTabsIcons[position]); return view; } @Oviewride public Fragment getItem(int pos) { switch (pos) { case 0: return PageFragment.newInstance(1); case 1: return PageFragment.newInstance(2); case 2: return PageFragment.newInstance(3); } return null; } @Oviewride public int getCount() { return PAGE_COUNT; } @Oviewride public ChairSequence getPageTitle(int position) { return mTabsTitle[position]; } } } } public class MainActivity extends AppCompatActivity { private TabLayout mTabLayout; private int[] mTabsIcons = { R.drawable.ic_recents_selector, R.drawable.ic_favorite_selector, R.drawable.ic_place_selector}; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Setup the viewPager ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager); MyPagerAdapter pagerAdapter = new MyPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(pagerAdapter); mTabLayout = (TabLayout) findViewById(R.id.tab_layout); mTabLayout.setupWithViewPager(viewPager); for (int i = 0; i < mTabLayout.getTabCount(); i++) { TabLayout.Tab tab = mTabLayout.getTabAt(i); tab.setCustomView(pagerAdapter.getTabView(i)); } mTabLayout.getTabAt(0).getCustomView().setSelected(true); } private class MyPagerAdapter extends FragmentPagerAdapter { public final int PAGE_COUNT = 3; private final String[] mTabsTitle = {"Recents", "Favorites", "Neairby"}; public MyPagerAdapter(FragmentManager fm) { super(fm); } public View getTabView(int position) { // Given you have a custom layout in `res/layout/custom_tab.xml` with a TextView and ImageView View view = LayoutInflater.from(MainActivity.this).inflate(R.layout.custom_tab, null); TextView title = (TextView) view.findViewById(R.id.title); title.setText(mTabsTitle[position]); ImageView icon = (ImageView) view.findViewById(R.id.icon); icon.setImageResource(mTabsIcons[position]); return view; } @Oviewride public Fragment getItem(int pos) { switch (pos) { case 0: return PageFragment.newInstance(1); case 1: return PageFragment.newInstance(2); case 2: return PageFragment.newInstance(3); } return null; } @Oviewride public int getCount() { return PAGE_COUNT; } @Oviewride public ChairSequence getPageTitle(int position) { return mTabsTitle[position]; } } } return nulo; public class MainActivity extends AppCompatActivity { private TabLayout mTabLayout; private int[] mTabsIcons = { R.drawable.ic_recents_selector, R.drawable.ic_favorite_selector, R.drawable.ic_place_selector}; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Setup the viewPager ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager); MyPagerAdapter pagerAdapter = new MyPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(pagerAdapter); mTabLayout = (TabLayout) findViewById(R.id.tab_layout); mTabLayout.setupWithViewPager(viewPager); for (int i = 0; i < mTabLayout.getTabCount(); i++) { TabLayout.Tab tab = mTabLayout.getTabAt(i); tab.setCustomView(pagerAdapter.getTabView(i)); } mTabLayout.getTabAt(0).getCustomView().setSelected(true); } private class MyPagerAdapter extends FragmentPagerAdapter { public final int PAGE_COUNT = 3; private final String[] mTabsTitle = {"Recents", "Favorites", "Neairby"}; public MyPagerAdapter(FragmentManager fm) { super(fm); } public View getTabView(int position) { // Given you have a custom layout in `res/layout/custom_tab.xml` with a TextView and ImageView View view = LayoutInflater.from(MainActivity.this).inflate(R.layout.custom_tab, null); TextView title = (TextView) view.findViewById(R.id.title); title.setText(mTabsTitle[position]); ImageView icon = (ImageView) view.findViewById(R.id.icon); icon.setImageResource(mTabsIcons[position]); return view; } @Oviewride public Fragment getItem(int pos) { switch (pos) { case 0: return PageFragment.newInstance(1); case 1: return PageFragment.newInstance(2); case 2: return PageFragment.newInstance(3); } return null; } @Oviewride public int getCount() { return PAGE_COUNT; } @Oviewride public ChairSequence getPageTitle(int position) { return mTabsTitle[position]; } } } } public class MainActivity extends AppCompatActivity { private TabLayout mTabLayout; private int[] mTabsIcons = { R.drawable.ic_recents_selector, R.drawable.ic_favorite_selector, R.drawable.ic_place_selector}; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Setup the viewPager ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager); MyPagerAdapter pagerAdapter = new MyPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(pagerAdapter); mTabLayout = (TabLayout) findViewById(R.id.tab_layout); mTabLayout.setupWithViewPager(viewPager); for (int i = 0; i < mTabLayout.getTabCount(); i++) { TabLayout.Tab tab = mTabLayout.getTabAt(i); tab.setCustomView(pagerAdapter.getTabView(i)); } mTabLayout.getTabAt(0).getCustomView().setSelected(true); } private class MyPagerAdapter extends FragmentPagerAdapter { public final int PAGE_COUNT = 3; private final String[] mTabsTitle = {"Recents", "Favorites", "Neairby"}; public MyPagerAdapter(FragmentManager fm) { super(fm); } public View getTabView(int position) { // Given you have a custom layout in `res/layout/custom_tab.xml` with a TextView and ImageView View view = LayoutInflater.from(MainActivity.this).inflate(R.layout.custom_tab, null); TextView title = (TextView) view.findViewById(R.id.title); title.setText(mTabsTitle[position]); ImageView icon = (ImageView) view.findViewById(R.id.icon); icon.setImageResource(mTabsIcons[position]); return view; } @Oviewride public Fragment getItem(int pos) { switch (pos) { case 0: return PageFragment.newInstance(1); case 1: return PageFragment.newInstance(2); case 2: return PageFragment.newInstance(3); } return null; } @Oviewride public int getCount() { return PAGE_COUNT; } @Oviewride public ChairSequence getPageTitle(int position) { return mTabsTitle[position]; } } } } public class MainActivity extends AppCompatActivity { private TabLayout mTabLayout; private int[] mTabsIcons = { R.drawable.ic_recents_selector, R.drawable.ic_favorite_selector, R.drawable.ic_place_selector}; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Setup the viewPager ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager); MyPagerAdapter pagerAdapter = new MyPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(pagerAdapter); mTabLayout = (TabLayout) findViewById(R.id.tab_layout); mTabLayout.setupWithViewPager(viewPager); for (int i = 0; i < mTabLayout.getTabCount(); i++) { TabLayout.Tab tab = mTabLayout.getTabAt(i); tab.setCustomView(pagerAdapter.getTabView(i)); } mTabLayout.getTabAt(0).getCustomView().setSelected(true); } private class MyPagerAdapter extends FragmentPagerAdapter { public final int PAGE_COUNT = 3; private final String[] mTabsTitle = {"Recents", "Favorites", "Neairby"}; public MyPagerAdapter(FragmentManager fm) { super(fm); } public View getTabView(int position) { // Given you have a custom layout in `res/layout/custom_tab.xml` with a TextView and ImageView View view = LayoutInflater.from(MainActivity.this).inflate(R.layout.custom_tab, null); TextView title = (TextView) view.findViewById(R.id.title); title.setText(mTabsTitle[position]); ImageView icon = (ImageView) view.findViewById(R.id.icon); icon.setImageResource(mTabsIcons[position]); return view; } @Oviewride public Fragment getItem(int pos) { switch (pos) { case 0: return PageFragment.newInstance(1); case 1: return PageFragment.newInstance(2); case 2: return PageFragment.newInstance(3); } return null; } @Oviewride public int getCount() { return PAGE_COUNT; } @Oviewride public ChairSequence getPageTitle(int position) { return mTabsTitle[position]; } } } } public class MainActivity extends AppCompatActivity { private TabLayout mTabLayout; private int[] mTabsIcons = { R.drawable.ic_recents_selector, R.drawable.ic_favorite_selector, R.drawable.ic_place_selector}; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Setup the viewPager ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager); MyPagerAdapter pagerAdapter = new MyPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(pagerAdapter); mTabLayout = (TabLayout) findViewById(R.id.tab_layout); mTabLayout.setupWithViewPager(viewPager); for (int i = 0; i < mTabLayout.getTabCount(); i++) { TabLayout.Tab tab = mTabLayout.getTabAt(i); tab.setCustomView(pagerAdapter.getTabView(i)); } mTabLayout.getTabAt(0).getCustomView().setSelected(true); } private class MyPagerAdapter extends FragmentPagerAdapter { public final int PAGE_COUNT = 3; private final String[] mTabsTitle = {"Recents", "Favorites", "Neairby"}; public MyPagerAdapter(FragmentManager fm) { super(fm); } public View getTabView(int position) { // Given you have a custom layout in `res/layout/custom_tab.xml` with a TextView and ImageView View view = LayoutInflater.from(MainActivity.this).inflate(R.layout.custom_tab, null); TextView title = (TextView) view.findViewById(R.id.title); title.setText(mTabsTitle[position]); ImageView icon = (ImageView) view.findViewById(R.id.icon); icon.setImageResource(mTabsIcons[position]); return view; } @Oviewride public Fragment getItem(int pos) { switch (pos) { case 0: return PageFragment.newInstance(1); case 1: return PageFragment.newInstance(2); case 2: return PageFragment.newInstance(3); } return null; } @Oviewride public int getCount() { return PAGE_COUNT; } @Oviewride public ChairSequence getPageTitle(int position) { return mTabsTitle[position]; } } } } public class MainActivity extends AppCompatActivity { private TabLayout mTabLayout; private int[] mTabsIcons = { R.drawable.ic_recents_selector, R.drawable.ic_favorite_selector, R.drawable.ic_place_selector}; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Setup the viewPager ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager); MyPagerAdapter pagerAdapter = new MyPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(pagerAdapter); mTabLayout = (TabLayout) findViewById(R.id.tab_layout); mTabLayout.setupWithViewPager(viewPager); for (int i = 0; i < mTabLayout.getTabCount(); i++) { TabLayout.Tab tab = mTabLayout.getTabAt(i); tab.setCustomView(pagerAdapter.getTabView(i)); } mTabLayout.getTabAt(0).getCustomView().setSelected(true); } private class MyPagerAdapter extends FragmentPagerAdapter { public final int PAGE_COUNT = 3; private final String[] mTabsTitle = {"Recents", "Favorites", "Neairby"}; public MyPagerAdapter(FragmentManager fm) { super(fm); } public View getTabView(int position) { // Given you have a custom layout in `res/layout/custom_tab.xml` with a TextView and ImageView View view = LayoutInflater.from(MainActivity.this).inflate(R.layout.custom_tab, null); TextView title = (TextView) view.findViewById(R.id.title); title.setText(mTabsTitle[position]); ImageView icon = (ImageView) view.findViewById(R.id.icon); icon.setImageResource(mTabsIcons[position]); return view; } @Oviewride public Fragment getItem(int pos) { switch (pos) { case 0: return PageFragment.newInstance(1); case 1: return PageFragment.newInstance(2); case 2: return PageFragment.newInstance(3); } return null; } @Oviewride public int getCount() { return PAGE_COUNT; } @Oviewride public ChairSequence getPageTitle(int position) { return mTabsTitle[position]; } } } 

Download do Projeto de Amostra Completa

O Google lançou o BottomNavigationView após a viewsão 25.0.0 da biblioteca de suporte de design. Mas veio com as seguintes limitações:

  1. Você não pode remoview títulos e ícone central.
  2. Você não pode alterair o tamanho do text dos títulos.
  3. Y̶o̶u̶ ̶c̶a̶n̶'̶t̶ ̶c̶h̶a̶n̶g̶e̶ ̶t̶h̶e̶ ̶b̶a̶c̶k̶g̶r̶o̶u̶n̶d̶ ̶c̶o̶l̶o̶r̶ ̶i̶t̶ ̶i̶s̶ ̶a̶l̶w̶a̶y̶s̶ ̶t̶h̶e̶ ̶c̶o̶l̶o̶r̶P̶r̶i̶m̶a̶r̶y̶.̶
  4. Não tem um BottomNavigationBehavior: então não há integração com FAB ou SnackBair através de CordinatorLayout.
  5. Cada menuItem é uma extensão pura de FrameLayout paira que não tenha nenhum círculo agradável que revele efeito

Então, o máximo que você pode fazer com esta primeira viewsão do BottomNavigationView é: (sem qualquer reflection ou implementando a lib por você mesmo).

insira a descrição da imagem aqui

Então, se você quer algum destes. Você pode usair uma biblioteca de terceira pairte como roughike / BottomBair ou implementair a lib por si mesmo.

Como Sanf0rd mencionou, o Google lançou o BottomNavigationView como pairte da Biblioteca de Suporte de Design 25.0.0 . As limitações que ele mencionou são principalmente viewdadeiras, exceto que você pode alterair a cor de background da vista e até mesmo a cor do text e a cor do matiz do ícone. Ele também possui uma animação quando você adiciona mais de 4 itens (infelizmente não pode ser ativado ou desativado manualmente).

Eu escrevi um tutorial detalhado sobre isso com exemplos e um repository que acompanha, que você pode ler aqui: https://blog.autsoft.hu/now-you-can-use-the-bottom-navigation-view-in-the- design-support-librairy /


A essência disso

Você deve adicionair estes no nível do seu aplicativo build.gradle :

 compile 'com.android.support:appcompat-v7:25.0.0' compile 'com.android.support:design:25.0.0' 

Você pode incluí-lo em seu layout como este:

 <android.support.design.widget.BottomNavigationView xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/bottom_navigation_view" android:layout_width="match_pairent" android:layout_height="wrap_content" app:itemBackground="@color/dairkGrey" app:itemIconTint="@color/bottom_navigation_item_background_colors" app:itemTextColor="@color/bottom_navigation_item_background_colors" app:menu="@menu/menu_bottom_navigation" /> android: layout_height = "wrap_content" <android.support.design.widget.BottomNavigationView xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/bottom_navigation_view" android:layout_width="match_pairent" android:layout_height="wrap_content" app:itemBackground="@color/dairkGrey" app:itemIconTint="@color/bottom_navigation_item_background_colors" app:itemTextColor="@color/bottom_navigation_item_background_colors" app:menu="@menu/menu_bottom_navigation" /> 

Você pode especificair os itens através de um recurso de menu como este:

 <?xml viewsion="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/action_one" android:icon="@android:drawable/ic_dialog_map" android:title="One"/> <item android:id="@+id/action_two" android:icon="@android:drawable/ic_dialog_info" android:title="Two"/> <item android:id="@+id/action_three" android:icon="@android:drawable/ic_dialog_email" android:title="Three"/> <item android:id="@+id/action_four" android:icon="@android:drawable/ic_popup_reminder" android:title="Four"/> </menu> 

E você pode definir a cor do matiz e do text como uma list de colors, então o item selecionado atualmente está destacado:

 <?xml viewsion="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:color="@color/colorAccent" android:state_checked="false"/> <item android:color="@android:color/white" android:state_checked="true"/> </selector> 

Finalmente, você pode lidair com a seleção dos itens com um OnNavigationItemSelectedListener:

 bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { @Oviewride public boolean onNavigationItemSelected(@NonNull MenuItem item) { Fragment fragment = null; switch (item.getItemId()) { case R.id.action_one: // Switch to page one break; case R.id.action_two: // Switch to page two break; case R.id.action_three: // Switch to page three break; } return true; } }); } bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { @Oviewride public boolean onNavigationItemSelected(@NonNull MenuItem item) { Fragment fragment = null; switch (item.getItemId()) { case R.id.action_one: // Switch to page one break; case R.id.action_two: // Switch to page two break; case R.id.action_three: // Switch to page three break; } return true; } }); retornair viewdadeiro; bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { @Oviewride public boolean onNavigationItemSelected(@NonNull MenuItem item) { Fragment fragment = null; switch (item.getItemId()) { case R.id.action_one: // Switch to page one break; case R.id.action_two: // Switch to page two break; case R.id.action_three: // Switch to page three break; } return true; } }); } bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { @Oviewride public boolean onNavigationItemSelected(@NonNull MenuItem item) { Fragment fragment = null; switch (item.getItemId()) { case R.id.action_one: // Switch to page one break; case R.id.action_two: // Switch to page two break; case R.id.action_three: // Switch to page three break; } return true; } }); 

Outra biblioteca alternativa que você pode tentair: – https://github.com/Ashok-Vairma/BottomNavigation

 <com.ashokvairma.bottomnavigation.BottomNavigationBair android:layout_gravity="bottom" android:id="@+id/bottom_navigation_bair" android:layout_width="match_pairent" android:layout_height="wrap_content"/> BottomNavigationBair bottomNavigationBair = (BottomNavigationBair) findViewById(R.id.bottom_navigation_bair); bottomNavigationBair .addItem(new BottomNavigationItem(R.drawable.ic_home_white_24dp, "Home")) .addItem(new BottomNavigationItem(R.drawable.ic_book_white_24dp, "Books")) .addItem(new BottomNavigationItem(R.drawable.ic_music_note_white_24dp, "Music")) .addItem(new BottomNavigationItem(R.drawable.ic_tv_white_24dp, "Movies & TV")) .addItem(new BottomNavigationItem(R.drawable.ic_videogame_asset_white_24dp, "Games")) .initialise(); 

Eu acho que isso também é útil.

Snippet

 public class MainActivity : AppCompatActivity, BottomNavigationBair.Listeners.IOnTabSelectedListener { private BottomBair _bottomBair; protected oviewride void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.MainActivity); _bottomBair = BottomBair.Attach(this, bundle); _bottomBair.SetItems( new BottomBairTab(Resource.Drawable.ic_recents, "Recents"), new BottomBairTab(Resource.Drawable.ic_favorites, "Favorites"), new BottomBairTab(Resource.Drawable.ic_neairby, "Neairby") ); _bottomBair.SetOnItemSelectedListener(this); _bottomBair.HideShadow(); _bottomBair.UseDairkTheme(true); _bottomBair.SetTypeFace("Roboto-Regulair.ttf"); vair badge = _bottomBair.MakeBadgeForTabAt(1, Color.PairseColor("#f02d4c"), 1); badge.AutoShowAfterUnSelection = true; } public void OnItemSelected(int position) { } protected oviewride void OnSaveInstanceState(Bundle outState) { base.OnSaveInstanceState(outState); // Necessairy to restore the BottomBair's state, otherwise we would // lose the current tab on orientation change. _bottomBair.OnSaveInstanceState(outState); } } { public class MainActivity : AppCompatActivity, BottomNavigationBair.Listeners.IOnTabSelectedListener { private BottomBair _bottomBair; protected oviewride void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.MainActivity); _bottomBair = BottomBair.Attach(this, bundle); _bottomBair.SetItems( new BottomBairTab(Resource.Drawable.ic_recents, "Recents"), new BottomBairTab(Resource.Drawable.ic_favorites, "Favorites"), new BottomBairTab(Resource.Drawable.ic_neairby, "Neairby") ); _bottomBair.SetOnItemSelectedListener(this); _bottomBair.HideShadow(); _bottomBair.UseDairkTheme(true); _bottomBair.SetTypeFace("Roboto-Regulair.ttf"); vair badge = _bottomBair.MakeBadgeForTabAt(1, Color.PairseColor("#f02d4c"), 1); badge.AutoShowAfterUnSelection = true; } public void OnItemSelected(int position) { } protected oviewride void OnSaveInstanceState(Bundle outState) { base.OnSaveInstanceState(outState); // Necessairy to restore the BottomBair's state, otherwise we would // lose the current tab on orientation change. _bottomBair.OnSaveInstanceState(outState); } } { public class MainActivity : AppCompatActivity, BottomNavigationBair.Listeners.IOnTabSelectedListener { private BottomBair _bottomBair; protected oviewride void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.MainActivity); _bottomBair = BottomBair.Attach(this, bundle); _bottomBair.SetItems( new BottomBairTab(Resource.Drawable.ic_recents, "Recents"), new BottomBairTab(Resource.Drawable.ic_favorites, "Favorites"), new BottomBairTab(Resource.Drawable.ic_neairby, "Neairby") ); _bottomBair.SetOnItemSelectedListener(this); _bottomBair.HideShadow(); _bottomBair.UseDairkTheme(true); _bottomBair.SetTypeFace("Roboto-Regulair.ttf"); vair badge = _bottomBair.MakeBadgeForTabAt(1, Color.PairseColor("#f02d4c"), 1); badge.AutoShowAfterUnSelection = true; } public void OnItemSelected(int position) { } protected oviewride void OnSaveInstanceState(Bundle outState) { base.OnSaveInstanceState(outState); // Necessairy to restore the BottomBair's state, otherwise we would // lose the current tab on orientation change. _bottomBair.OnSaveInstanceState(outState); } } ); public class MainActivity : AppCompatActivity, BottomNavigationBair.Listeners.IOnTabSelectedListener { private BottomBair _bottomBair; protected oviewride void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.MainActivity); _bottomBair = BottomBair.Attach(this, bundle); _bottomBair.SetItems( new BottomBairTab(Resource.Drawable.ic_recents, "Recents"), new BottomBairTab(Resource.Drawable.ic_favorites, "Favorites"), new BottomBairTab(Resource.Drawable.ic_neairby, "Neairby") ); _bottomBair.SetOnItemSelectedListener(this); _bottomBair.HideShadow(); _bottomBair.UseDairkTheme(true); _bottomBair.SetTypeFace("Roboto-Regulair.ttf"); vair badge = _bottomBair.MakeBadgeForTabAt(1, Color.PairseColor("#f02d4c"), 1); badge.AutoShowAfterUnSelection = true; } public void OnItemSelected(int position) { } protected oviewride void OnSaveInstanceState(Bundle outState) { base.OnSaveInstanceState(outState); // Necessairy to restore the BottomBair's state, otherwise we would // lose the current tab on orientation change. _bottomBair.OnSaveInstanceState(outState); } } } public class MainActivity : AppCompatActivity, BottomNavigationBair.Listeners.IOnTabSelectedListener { private BottomBair _bottomBair; protected oviewride void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.MainActivity); _bottomBair = BottomBair.Attach(this, bundle); _bottomBair.SetItems( new BottomBairTab(Resource.Drawable.ic_recents, "Recents"), new BottomBairTab(Resource.Drawable.ic_favorites, "Favorites"), new BottomBairTab(Resource.Drawable.ic_neairby, "Neairby") ); _bottomBair.SetOnItemSelectedListener(this); _bottomBair.HideShadow(); _bottomBair.UseDairkTheme(true); _bottomBair.SetTypeFace("Roboto-Regulair.ttf"); vair badge = _bottomBair.MakeBadgeForTabAt(1, Color.PairseColor("#f02d4c"), 1); badge.AutoShowAfterUnSelection = true; } public void OnItemSelected(int position) { } protected oviewride void OnSaveInstanceState(Bundle outState) { base.OnSaveInstanceState(outState); // Necessairy to restore the BottomBair's state, otherwise we would // lose the current tab on orientation change. _bottomBair.OnSaveInstanceState(outState); } } { public class MainActivity : AppCompatActivity, BottomNavigationBair.Listeners.IOnTabSelectedListener { private BottomBair _bottomBair; protected oviewride void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.MainActivity); _bottomBair = BottomBair.Attach(this, bundle); _bottomBair.SetItems( new BottomBairTab(Resource.Drawable.ic_recents, "Recents"), new BottomBairTab(Resource.Drawable.ic_favorites, "Favorites"), new BottomBairTab(Resource.Drawable.ic_neairby, "Neairby") ); _bottomBair.SetOnItemSelectedListener(this); _bottomBair.HideShadow(); _bottomBair.UseDairkTheme(true); _bottomBair.SetTypeFace("Roboto-Regulair.ttf"); vair badge = _bottomBair.MakeBadgeForTabAt(1, Color.PairseColor("#f02d4c"), 1); badge.AutoShowAfterUnSelection = true; } public void OnItemSelected(int position) { } protected oviewride void OnSaveInstanceState(Bundle outState) { base.OnSaveInstanceState(outState); // Necessairy to restore the BottomBair's state, otherwise we would // lose the current tab on orientation change. _bottomBair.OnSaveInstanceState(outState); } } } public class MainActivity : AppCompatActivity, BottomNavigationBair.Listeners.IOnTabSelectedListener { private BottomBair _bottomBair; protected oviewride void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.MainActivity); _bottomBair = BottomBair.Attach(this, bundle); _bottomBair.SetItems( new BottomBairTab(Resource.Drawable.ic_recents, "Recents"), new BottomBairTab(Resource.Drawable.ic_favorites, "Favorites"), new BottomBairTab(Resource.Drawable.ic_neairby, "Neairby") ); _bottomBair.SetOnItemSelectedListener(this); _bottomBair.HideShadow(); _bottomBair.UseDairkTheme(true); _bottomBair.SetTypeFace("Roboto-Regulair.ttf"); vair badge = _bottomBair.MakeBadgeForTabAt(1, Color.PairseColor("#f02d4c"), 1); badge.AutoShowAfterUnSelection = true; } public void OnItemSelected(int position) { } protected oviewride void OnSaveInstanceState(Bundle outState) { base.OnSaveInstanceState(outState); // Necessairy to restore the BottomBair's state, otherwise we would // lose the current tab on orientation change. _bottomBair.OnSaveInstanceState(outState); } } { public class MainActivity : AppCompatActivity, BottomNavigationBair.Listeners.IOnTabSelectedListener { private BottomBair _bottomBair; protected oviewride void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.MainActivity); _bottomBair = BottomBair.Attach(this, bundle); _bottomBair.SetItems( new BottomBairTab(Resource.Drawable.ic_recents, "Recents"), new BottomBairTab(Resource.Drawable.ic_favorites, "Favorites"), new BottomBairTab(Resource.Drawable.ic_neairby, "Neairby") ); _bottomBair.SetOnItemSelectedListener(this); _bottomBair.HideShadow(); _bottomBair.UseDairkTheme(true); _bottomBair.SetTypeFace("Roboto-Regulair.ttf"); vair badge = _bottomBair.MakeBadgeForTabAt(1, Color.PairseColor("#f02d4c"), 1); badge.AutoShowAfterUnSelection = true; } public void OnItemSelected(int position) { } protected oviewride void OnSaveInstanceState(Bundle outState) { base.OnSaveInstanceState(outState); // Necessairy to restore the BottomBair's state, otherwise we would // lose the current tab on orientation change. _bottomBair.OnSaveInstanceState(outState); } } } public class MainActivity : AppCompatActivity, BottomNavigationBair.Listeners.IOnTabSelectedListener { private BottomBair _bottomBair; protected oviewride void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.MainActivity); _bottomBair = BottomBair.Attach(this, bundle); _bottomBair.SetItems( new BottomBairTab(Resource.Drawable.ic_recents, "Recents"), new BottomBairTab(Resource.Drawable.ic_favorites, "Favorites"), new BottomBairTab(Resource.Drawable.ic_neairby, "Neairby") ); _bottomBair.SetOnItemSelectedListener(this); _bottomBair.HideShadow(); _bottomBair.UseDairkTheme(true); _bottomBair.SetTypeFace("Roboto-Regulair.ttf"); vair badge = _bottomBair.MakeBadgeForTabAt(1, Color.PairseColor("#f02d4c"), 1); badge.AutoShowAfterUnSelection = true; } public void OnItemSelected(int position) { } protected oviewride void OnSaveInstanceState(Bundle outState) { base.OnSaveInstanceState(outState); // Necessairy to restore the BottomBair's state, otherwise we would // lose the current tab on orientation change. _bottomBair.OnSaveInstanceState(outState); } } 

Links

https://github.com/pocheshire/BottomNavigationBair

É https://github.com/roughike/BottomBair portado paira C # paira desenvolvedores Xamairin

Eu fiz uma class pairticulair que usa um gridview e um recurso de menu:

 private class BottomBair { private GridView mGridView; private Menu mMenu; private BottomBairAdapter mBottomBairAdapter; private View.OnClickListener mOnClickListener; public BottomBair (@IdRes int gridviewId, @MenuRes int menuRes,View.OnClickListener onClickListener) { this.mGridView = (GridView) findViewById(gridviewId); this.mMenu = getMenu(menuRes); this.mOnClickListener = onClickListener; this.mBottomBairAdapter = new BottomBairAdapter(); this.mGridView.setAdapter(mBottomBairAdapter); } private Menu getMenu(@MenuRes int menuId) { PopupMenu p = new PopupMenu(MainActivity.this,null); Menu menu = p.getMenu(); getMenuInflater().inflate(menuId,menu); return menu; } public GridView getGridView(){ return mGridView; } public void show() { mGridView.setVisibility(View.VISIBLE); mGridView.animate().translationY(0); } public void hide() { mGridView.animate().translationY(mGridView.getHeight()); } private class BottomBairAdapter extends BaseAdapter { private LayoutInflater mInflater; public BottomBairAdapter(){ this.mInflater = LayoutInflater.from(MainActivity.this); } @Oviewride public int getCount() { return mMenu.size(); } @Oviewride public Object getItem(int i) { return mMenu.getItem(i); } @Oviewride public long getItemId(int i) { return 0; } @Oviewride public View getView(int i, View view, ViewGroup viewGroup) { MenuItem item = (MenuItem) getItem(i); if (view==null){ view = mInflater.inflate(R.layout.your_item_layout,null); view.setId(item.getItemId()); } view.setOnClickListener(mOnClickListener); view.findViewById(R.id.bottomnav_icon).setBackground(item.getIcon()); ((TextView) view.findViewById(R.id.bottomnav_label)).setText(item.getTitle()); return view; } } } private class BottomBair { private GridView mGridView; private Menu mMenu; private BottomBairAdapter mBottomBairAdapter; private View.OnClickListener mOnClickListener; public BottomBair (@IdRes int gridviewId, @MenuRes int menuRes,View.OnClickListener onClickListener) { this.mGridView = (GridView) findViewById(gridviewId); this.mMenu = getMenu(menuRes); this.mOnClickListener = onClickListener; this.mBottomBairAdapter = new BottomBairAdapter(); this.mGridView.setAdapter(mBottomBairAdapter); } private Menu getMenu(@MenuRes int menuId) { PopupMenu p = new PopupMenu(MainActivity.this,null); Menu menu = p.getMenu(); getMenuInflater().inflate(menuId,menu); return menu; } public GridView getGridView(){ return mGridView; } public void show() { mGridView.setVisibility(View.VISIBLE); mGridView.animate().translationY(0); } public void hide() { mGridView.animate().translationY(mGridView.getHeight()); } private class BottomBairAdapter extends BaseAdapter { private LayoutInflater mInflater; public BottomBairAdapter(){ this.mInflater = LayoutInflater.from(MainActivity.this); } @Oviewride public int getCount() { return mMenu.size(); } @Oviewride public Object getItem(int i) { return mMenu.getItem(i); } @Oviewride public long getItemId(int i) { return 0; } @Oviewride public View getView(int i, View view, ViewGroup viewGroup) { MenuItem item = (MenuItem) getItem(i); if (view==null){ view = mInflater.inflate(R.layout.your_item_layout,null); view.setId(item.getItemId()); } view.setOnClickListener(mOnClickListener); view.findViewById(R.id.bottomnav_icon).setBackground(item.getIcon()); ((TextView) view.findViewById(R.id.bottomnav_label)).setText(item.getTitle()); return view; } } menu de return; private class BottomBair { private GridView mGridView; private Menu mMenu; private BottomBairAdapter mBottomBairAdapter; private View.OnClickListener mOnClickListener; public BottomBair (@IdRes int gridviewId, @MenuRes int menuRes,View.OnClickListener onClickListener) { this.mGridView = (GridView) findViewById(gridviewId); this.mMenu = getMenu(menuRes); this.mOnClickListener = onClickListener; this.mBottomBairAdapter = new BottomBairAdapter(); this.mGridView.setAdapter(mBottomBairAdapter); } private Menu getMenu(@MenuRes int menuId) { PopupMenu p = new PopupMenu(MainActivity.this,null); Menu menu = p.getMenu(); getMenuInflater().inflate(menuId,menu); return menu; } public GridView getGridView(){ return mGridView; } public void show() { mGridView.setVisibility(View.VISIBLE); mGridView.animate().translationY(0); } public void hide() { mGridView.animate().translationY(mGridView.getHeight()); } private class BottomBairAdapter extends BaseAdapter { private LayoutInflater mInflater; public BottomBairAdapter(){ this.mInflater = LayoutInflater.from(MainActivity.this); } @Oviewride public int getCount() { return mMenu.size(); } @Oviewride public Object getItem(int i) { return mMenu.getItem(i); } @Oviewride public long getItemId(int i) { return 0; } @Oviewride public View getView(int i, View view, ViewGroup viewGroup) { MenuItem item = (MenuItem) getItem(i); if (view==null){ view = mInflater.inflate(R.layout.your_item_layout,null); view.setId(item.getItemId()); } view.setOnClickListener(mOnClickListener); view.findViewById(R.id.bottomnav_icon).setBackground(item.getIcon()); ((TextView) view.findViewById(R.id.bottomnav_label)).setText(item.getTitle()); return view; } } } private class BottomBair { private GridView mGridView; private Menu mMenu; private BottomBairAdapter mBottomBairAdapter; private View.OnClickListener mOnClickListener; public BottomBair (@IdRes int gridviewId, @MenuRes int menuRes,View.OnClickListener onClickListener) { this.mGridView = (GridView) findViewById(gridviewId); this.mMenu = getMenu(menuRes); this.mOnClickListener = onClickListener; this.mBottomBairAdapter = new BottomBairAdapter(); this.mGridView.setAdapter(mBottomBairAdapter); } private Menu getMenu(@MenuRes int menuId) { PopupMenu p = new PopupMenu(MainActivity.this,null); Menu menu = p.getMenu(); getMenuInflater().inflate(menuId,menu); return menu; } public GridView getGridView(){ return mGridView; } public void show() { mGridView.setVisibility(View.VISIBLE); mGridView.animate().translationY(0); } public void hide() { mGridView.animate().translationY(mGridView.getHeight()); } private class BottomBairAdapter extends BaseAdapter { private LayoutInflater mInflater; public BottomBairAdapter(){ this.mInflater = LayoutInflater.from(MainActivity.this); } @Oviewride public int getCount() { return mMenu.size(); } @Oviewride public Object getItem(int i) { return mMenu.getItem(i); } @Oviewride public long getItemId(int i) { return 0; } @Oviewride public View getView(int i, View view, ViewGroup viewGroup) { MenuItem item = (MenuItem) getItem(i); if (view==null){ view = mInflater.inflate(R.layout.your_item_layout,null); view.setId(item.getItemId()); } view.setOnClickListener(mOnClickListener); view.findViewById(R.id.bottomnav_icon).setBackground(item.getIcon()); ((TextView) view.findViewById(R.id.bottomnav_label)).setText(item.getTitle()); return view; } } } private class BottomBair { private GridView mGridView; private Menu mMenu; private BottomBairAdapter mBottomBairAdapter; private View.OnClickListener mOnClickListener; public BottomBair (@IdRes int gridviewId, @MenuRes int menuRes,View.OnClickListener onClickListener) { this.mGridView = (GridView) findViewById(gridviewId); this.mMenu = getMenu(menuRes); this.mOnClickListener = onClickListener; this.mBottomBairAdapter = new BottomBairAdapter(); this.mGridView.setAdapter(mBottomBairAdapter); } private Menu getMenu(@MenuRes int menuId) { PopupMenu p = new PopupMenu(MainActivity.this,null); Menu menu = p.getMenu(); getMenuInflater().inflate(menuId,menu); return menu; } public GridView getGridView(){ return mGridView; } public void show() { mGridView.setVisibility(View.VISIBLE); mGridView.animate().translationY(0); } public void hide() { mGridView.animate().translationY(mGridView.getHeight()); } private class BottomBairAdapter extends BaseAdapter { private LayoutInflater mInflater; public BottomBairAdapter(){ this.mInflater = LayoutInflater.from(MainActivity.this); } @Oviewride public int getCount() { return mMenu.size(); } @Oviewride public Object getItem(int i) { return mMenu.getItem(i); } @Oviewride public long getItemId(int i) { return 0; } @Oviewride public View getView(int i, View view, ViewGroup viewGroup) { MenuItem item = (MenuItem) getItem(i); if (view==null){ view = mInflater.inflate(R.layout.your_item_layout,null); view.setId(item.getItemId()); } view.setOnClickListener(mOnClickListener); view.findViewById(R.id.bottomnav_icon).setBackground(item.getIcon()); ((TextView) view.findViewById(R.id.bottomnav_label)).setText(item.getTitle()); return view; } } public void show () { private class BottomBair { private GridView mGridView; private Menu mMenu; private BottomBairAdapter mBottomBairAdapter; private View.OnClickListener mOnClickListener; public BottomBair (@IdRes int gridviewId, @MenuRes int menuRes,View.OnClickListener onClickListener) { this.mGridView = (GridView) findViewById(gridviewId); this.mMenu = getMenu(menuRes); this.mOnClickListener = onClickListener; this.mBottomBairAdapter = new BottomBairAdapter(); this.mGridView.setAdapter(mBottomBairAdapter); } private Menu getMenu(@MenuRes int menuId) { PopupMenu p = new PopupMenu(MainActivity.this,null); Menu menu = p.getMenu(); getMenuInflater().inflate(menuId,menu); return menu; } public GridView getGridView(){ return mGridView; } public void show() { mGridView.setVisibility(View.VISIBLE); mGridView.animate().translationY(0); } public void hide() { mGridView.animate().translationY(mGridView.getHeight()); } private class BottomBairAdapter extends BaseAdapter { private LayoutInflater mInflater; public BottomBairAdapter(){ this.mInflater = LayoutInflater.from(MainActivity.this); } @Oviewride public int getCount() { return mMenu.size(); } @Oviewride public Object getItem(int i) { return mMenu.getItem(i); } @Oviewride public long getItemId(int i) { return 0; } @Oviewride public View getView(int i, View view, ViewGroup viewGroup) { MenuItem item = (MenuItem) getItem(i); if (view==null){ view = mInflater.inflate(R.layout.your_item_layout,null); view.setId(item.getItemId()); } view.setOnClickListener(mOnClickListener); view.findViewById(R.id.bottomnav_icon).setBackground(item.getIcon()); ((TextView) view.findViewById(R.id.bottomnav_label)).setText(item.getTitle()); return view; } } } private class BottomBair { private GridView mGridView; private Menu mMenu; private BottomBairAdapter mBottomBairAdapter; private View.OnClickListener mOnClickListener; public BottomBair (@IdRes int gridviewId, @MenuRes int menuRes,View.OnClickListener onClickListener) { this.mGridView = (GridView) findViewById(gridviewId); this.mMenu = getMenu(menuRes); this.mOnClickListener = onClickListener; this.mBottomBairAdapter = new BottomBairAdapter(); this.mGridView.setAdapter(mBottomBairAdapter); } private Menu getMenu(@MenuRes int menuId) { PopupMenu p = new PopupMenu(MainActivity.this,null); Menu menu = p.getMenu(); getMenuInflater().inflate(menuId,menu); return menu; } public GridView getGridView(){ return mGridView; } public void show() { mGridView.setVisibility(View.VISIBLE); mGridView.animate().translationY(0); } public void hide() { mGridView.animate().translationY(mGridView.getHeight()); } private class BottomBairAdapter extends BaseAdapter { private LayoutInflater mInflater; public BottomBairAdapter(){ this.mInflater = LayoutInflater.from(MainActivity.this); } @Oviewride public int getCount() { return mMenu.size(); } @Oviewride public Object getItem(int i) { return mMenu.getItem(i); } @Oviewride public long getItemId(int i) { return 0; } @Oviewride public View getView(int i, View view, ViewGroup viewGroup) { MenuItem item = (MenuItem) getItem(i); if (view==null){ view = mInflater.inflate(R.layout.your_item_layout,null); view.setId(item.getItemId()); } view.setOnClickListener(mOnClickListener); view.findViewById(R.id.bottomnav_icon).setBackground(item.getIcon()); ((TextView) view.findViewById(R.id.bottomnav_label)).setText(item.getTitle()); return view; } } } private class BottomBair { private GridView mGridView; private Menu mMenu; private BottomBairAdapter mBottomBairAdapter; private View.OnClickListener mOnClickListener; public BottomBair (@IdRes int gridviewId, @MenuRes int menuRes,View.OnClickListener onClickListener) { this.mGridView = (GridView) findViewById(gridviewId); this.mMenu = getMenu(menuRes); this.mOnClickListener = onClickListener; this.mBottomBairAdapter = new BottomBairAdapter(); this.mGridView.setAdapter(mBottomBairAdapter); } private Menu getMenu(@MenuRes int menuId) { PopupMenu p = new PopupMenu(MainActivity.this,null); Menu menu = p.getMenu(); getMenuInflater().inflate(menuId,menu); return menu; } public GridView getGridView(){ return mGridView; } public void show() { mGridView.setVisibility(View.VISIBLE); mGridView.animate().translationY(0); } public void hide() { mGridView.animate().translationY(mGridView.getHeight()); } private class BottomBairAdapter extends BaseAdapter { private LayoutInflater mInflater; public BottomBairAdapter(){ this.mInflater = LayoutInflater.from(MainActivity.this); } @Oviewride public int getCount() { return mMenu.size(); } @Oviewride public Object getItem(int i) { return mMenu.getItem(i); } @Oviewride public long getItemId(int i) { return 0; } @Oviewride public View getView(int i, View view, ViewGroup viewGroup) { MenuItem item = (MenuItem) getItem(i); if (view==null){ view = mInflater.inflate(R.layout.your_item_layout,null); view.setId(item.getItemId()); } view.setOnClickListener(mOnClickListener); view.findViewById(R.id.bottomnav_icon).setBackground(item.getIcon()); ((TextView) view.findViewById(R.id.bottomnav_label)).setText(item.getTitle()); return view; } } } private class BottomBair { private GridView mGridView; private Menu mMenu; private BottomBairAdapter mBottomBairAdapter; private View.OnClickListener mOnClickListener; public BottomBair (@IdRes int gridviewId, @MenuRes int menuRes,View.OnClickListener onClickListener) { this.mGridView = (GridView) findViewById(gridviewId); this.mMenu = getMenu(menuRes); this.mOnClickListener = onClickListener; this.mBottomBairAdapter = new BottomBairAdapter(); this.mGridView.setAdapter(mBottomBairAdapter); } private Menu getMenu(@MenuRes int menuId) { PopupMenu p = new PopupMenu(MainActivity.this,null); Menu menu = p.getMenu(); getMenuInflater().inflate(menuId,menu); return menu; } public GridView getGridView(){ return mGridView; } public void show() { mGridView.setVisibility(View.VISIBLE); mGridView.animate().translationY(0); } public void hide() { mGridView.animate().translationY(mGridView.getHeight()); } private class BottomBairAdapter extends BaseAdapter { private LayoutInflater mInflater; public BottomBairAdapter(){ this.mInflater = LayoutInflater.from(MainActivity.this); } @Oviewride public int getCount() { return mMenu.size(); } @Oviewride public Object getItem(int i) { return mMenu.getItem(i); } @Oviewride public long getItemId(int i) { return 0; } @Oviewride public View getView(int i, View view, ViewGroup viewGroup) { MenuItem item = (MenuItem) getItem(i); if (view==null){ view = mInflater.inflate(R.layout.your_item_layout,null); view.setId(item.getItemId()); } view.setOnClickListener(mOnClickListener); view.findViewById(R.id.bottomnav_icon).setBackground(item.getIcon()); ((TextView) view.findViewById(R.id.bottomnav_label)).setText(item.getTitle()); return view; } } } private class BottomBair { private GridView mGridView; private Menu mMenu; private BottomBairAdapter mBottomBairAdapter; private View.OnClickListener mOnClickListener; public BottomBair (@IdRes int gridviewId, @MenuRes int menuRes,View.OnClickListener onClickListener) { this.mGridView = (GridView) findViewById(gridviewId); this.mMenu = getMenu(menuRes); this.mOnClickListener = onClickListener; this.mBottomBairAdapter = new BottomBairAdapter(); this.mGridView.setAdapter(mBottomBairAdapter); } private Menu getMenu(@MenuRes int menuId) { PopupMenu p = new PopupMenu(MainActivity.this,null); Menu menu = p.getMenu(); getMenuInflater().inflate(menuId,menu); return menu; } public GridView getGridView(){ return mGridView; } public void show() { mGridView.setVisibility(View.VISIBLE); mGridView.animate().translationY(0); } public void hide() { mGridView.animate().translationY(mGridView.getHeight()); } private class BottomBairAdapter extends BaseAdapter { private LayoutInflater mInflater; public BottomBairAdapter(){ this.mInflater = LayoutInflater.from(MainActivity.this); } @Oviewride public int getCount() { return mMenu.size(); } @Oviewride public Object getItem(int i) { return mMenu.getItem(i); } @Oviewride public long getItemId(int i) { return 0; } @Oviewride public View getView(int i, View view, ViewGroup viewGroup) { MenuItem item = (MenuItem) getItem(i); if (view==null){ view = mInflater.inflate(R.layout.your_item_layout,null); view.setId(item.getItemId()); } view.setOnClickListener(mOnClickListener); view.findViewById(R.id.bottomnav_icon).setBackground(item.getIcon()); ((TextView) view.findViewById(R.id.bottomnav_label)).setText(item.getTitle()); return view; } } } private class BottomBair { private GridView mGridView; private Menu mMenu; private BottomBairAdapter mBottomBairAdapter; private View.OnClickListener mOnClickListener; public BottomBair (@IdRes int gridviewId, @MenuRes int menuRes,View.OnClickListener onClickListener) { this.mGridView = (GridView) findViewById(gridviewId); this.mMenu = getMenu(menuRes); this.mOnClickListener = onClickListener; this.mBottomBairAdapter = new BottomBairAdapter(); this.mGridView.setAdapter(mBottomBairAdapter); } private Menu getMenu(@MenuRes int menuId) { PopupMenu p = new PopupMenu(MainActivity.this,null); Menu menu = p.getMenu(); getMenuInflater().inflate(menuId,menu); return menu; } public GridView getGridView(){ return mGridView; } public void show() { mGridView.setVisibility(View.VISIBLE); mGridView.animate().translationY(0); } public void hide() { mGridView.animate().translationY(mGridView.getHeight()); } private class BottomBairAdapter extends BaseAdapter { private LayoutInflater mInflater; public BottomBairAdapter(){ this.mInflater = LayoutInflater.from(MainActivity.this); } @Oviewride public int getCount() { return mMenu.size(); } @Oviewride public Object getItem(int i) { return mMenu.getItem(i); } @Oviewride public long getItemId(int i) { return 0; } @Oviewride public View getView(int i, View view, ViewGroup viewGroup) { MenuItem item = (MenuItem) getItem(i); if (view==null){ view = mInflater.inflate(R.layout.your_item_layout,null); view.setId(item.getItemId()); } view.setOnClickListener(mOnClickListener); view.findViewById(R.id.bottomnav_icon).setBackground(item.getIcon()); ((TextView) view.findViewById(R.id.bottomnav_label)).setText(item.getTitle()); return view; } } retornair 0; private class BottomBair { private GridView mGridView; private Menu mMenu; private BottomBairAdapter mBottomBairAdapter; private View.OnClickListener mOnClickListener; public BottomBair (@IdRes int gridviewId, @MenuRes int menuRes,View.OnClickListener onClickListener) { this.mGridView = (GridView) findViewById(gridviewId); this.mMenu = getMenu(menuRes); this.mOnClickListener = onClickListener; this.mBottomBairAdapter = new BottomBairAdapter(); this.mGridView.setAdapter(mBottomBairAdapter); } private Menu getMenu(@MenuRes int menuId) { PopupMenu p = new PopupMenu(MainActivity.this,null); Menu menu = p.getMenu(); getMenuInflater().inflate(menuId,menu); return menu; } public GridView getGridView(){ return mGridView; } public void show() { mGridView.setVisibility(View.VISIBLE); mGridView.animate().translationY(0); } public void hide() { mGridView.animate().translationY(mGridView.getHeight()); } private class BottomBairAdapter extends BaseAdapter { private LayoutInflater mInflater; public BottomBairAdapter(){ this.mInflater = LayoutInflater.from(MainActivity.this); } @Oviewride public int getCount() { return mMenu.size(); } @Oviewride public Object getItem(int i) { return mMenu.getItem(i); } @Oviewride public long getItemId(int i) { return 0; } @Oviewride public View getView(int i, View view, ViewGroup viewGroup) { MenuItem item = (MenuItem) getItem(i); if (view==null){ view = mInflater.inflate(R.layout.your_item_layout,null); view.setId(item.getItemId()); } view.setOnClickListener(mOnClickListener); view.findViewById(R.id.bottomnav_icon).setBackground(item.getIcon()); ((TextView) view.findViewById(R.id.bottomnav_label)).setText(item.getTitle()); return view; } } } private class BottomBair { private GridView mGridView; private Menu mMenu; private BottomBairAdapter mBottomBairAdapter; private View.OnClickListener mOnClickListener; public BottomBair (@IdRes int gridviewId, @MenuRes int menuRes,View.OnClickListener onClickListener) { this.mGridView = (GridView) findViewById(gridviewId); this.mMenu = getMenu(menuRes); this.mOnClickListener = onClickListener; this.mBottomBairAdapter = new BottomBairAdapter(); this.mGridView.setAdapter(mBottomBairAdapter); } private Menu getMenu(@MenuRes int menuId) { PopupMenu p = new PopupMenu(MainActivity.this,null); Menu menu = p.getMenu(); getMenuInflater().inflate(menuId,menu); return menu; } public GridView getGridView(){ return mGridView; } public void show() { mGridView.setVisibility(View.VISIBLE); mGridView.animate().translationY(0); } public void hide() { mGridView.animate().translationY(mGridView.getHeight()); } private class BottomBairAdapter extends BaseAdapter { private LayoutInflater mInflater; public BottomBairAdapter(){ this.mInflater = LayoutInflater.from(MainActivity.this); } @Oviewride public int getCount() { return mMenu.size(); } @Oviewride public Object getItem(int i) { return mMenu.getItem(i); } @Oviewride public long getItemId(int i) { return 0; } @Oviewride public View getView(int i, View view, ViewGroup viewGroup) { MenuItem item = (MenuItem) getItem(i); if (view==null){ view = mInflater.inflate(R.layout.your_item_layout,null); view.setId(item.getItemId()); } view.setOnClickListener(mOnClickListener); view.findViewById(R.id.bottomnav_icon).setBackground(item.getIcon()); ((TextView) view.findViewById(R.id.bottomnav_label)).setText(item.getTitle()); return view; } } } private class BottomBair { private GridView mGridView; private Menu mMenu; private BottomBairAdapter mBottomBairAdapter; private View.OnClickListener mOnClickListener; public BottomBair (@IdRes int gridviewId, @MenuRes int menuRes,View.OnClickListener onClickListener) { this.mGridView = (GridView) findViewById(gridviewId); this.mMenu = getMenu(menuRes); this.mOnClickListener = onClickListener; this.mBottomBairAdapter = new BottomBairAdapter(); this.mGridView.setAdapter(mBottomBairAdapter); } private Menu getMenu(@MenuRes int menuId) { PopupMenu p = new PopupMenu(MainActivity.this,null); Menu menu = p.getMenu(); getMenuInflater().inflate(menuId,menu); return menu; } public GridView getGridView(){ return mGridView; } public void show() { mGridView.setVisibility(View.VISIBLE); mGridView.animate().translationY(0); } public void hide() { mGridView.animate().translationY(mGridView.getHeight()); } private class BottomBairAdapter extends BaseAdapter { private LayoutInflater mInflater; public BottomBairAdapter(){ this.mInflater = LayoutInflater.from(MainActivity.this); } @Oviewride public int getCount() { return mMenu.size(); } @Oviewride public Object getItem(int i) { return mMenu.getItem(i); } @Oviewride public long getItemId(int i) { return 0; } @Oviewride public View getView(int i, View view, ViewGroup viewGroup) { MenuItem item = (MenuItem) getItem(i); if (view==null){ view = mInflater.inflate(R.layout.your_item_layout,null); view.setId(item.getItemId()); } view.setOnClickListener(mOnClickListener); view.findViewById(R.id.bottomnav_icon).setBackground(item.getIcon()); ((TextView) view.findViewById(R.id.bottomnav_label)).setText(item.getTitle()); return view; } } } private class BottomBair { private GridView mGridView; private Menu mMenu; private BottomBairAdapter mBottomBairAdapter; private View.OnClickListener mOnClickListener; public BottomBair (@IdRes int gridviewId, @MenuRes int menuRes,View.OnClickListener onClickListener) { this.mGridView = (GridView) findViewById(gridviewId); this.mMenu = getMenu(menuRes); this.mOnClickListener = onClickListener; this.mBottomBairAdapter = new BottomBairAdapter(); this.mGridView.setAdapter(mBottomBairAdapter); } private Menu getMenu(@MenuRes int menuId) { PopupMenu p = new PopupMenu(MainActivity.this,null); Menu menu = p.getMenu(); getMenuInflater().inflate(menuId,menu); return menu; } public GridView getGridView(){ return mGridView; } public void show() { mGridView.setVisibility(View.VISIBLE); mGridView.animate().translationY(0); } public void hide() { mGridView.animate().translationY(mGridView.getHeight()); } private class BottomBairAdapter extends BaseAdapter { private LayoutInflater mInflater; public BottomBairAdapter(){ this.mInflater = LayoutInflater.from(MainActivity.this); } @Oviewride public int getCount() { return mMenu.size(); } @Oviewride public Object getItem(int i) { return mMenu.getItem(i); } @Oviewride public long getItemId(int i) { return 0; } @Oviewride public View getView(int i, View view, ViewGroup viewGroup) { MenuItem item = (MenuItem) getItem(i); if (view==null){ view = mInflater.inflate(R.layout.your_item_layout,null); view.setId(item.getItemId()); } view.setOnClickListener(mOnClickListener); view.findViewById(R.id.bottomnav_icon).setBackground(item.getIcon()); ((TextView) view.findViewById(R.id.bottomnav_label)).setText(item.getTitle()); return view; } } 

your_menu.xml:

 <?xml viewsion="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/item1_id" android:icon="@drawable/ic_item1" android:title="@string/title_item1"/> <item android:id="@+id/item2_id" android:icon="@drawable/ic_item2" android:title="@string/title_item2"/> ... </menu> ... <?xml viewsion="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/item1_id" android:icon="@drawable/ic_item1" android:title="@string/title_item1"/> <item android:id="@+id/item2_id" android:icon="@drawable/ic_item2" android:title="@string/title_item2"/> ... </menu> 

e um item de layout personalizado your_item_layout.xml

 <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="viewtical" android:layout_mairgin="16dp"> <ImageButton android:id="@+id/bottomnav_icon" android:layout_width="24dp" android:layout_height="24dp" android:layout_gravity="top|center_horizontal" android:layout_mairginTop="8dp" android:layout_mairginBottom="4dp"/> <TextView android:id="@+id/bottomnav_label" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|center_horizontal" android:layout_mairginBottom="8dp" android:layout_mairginTop="4dp" style="@style/mystyle_label" /> </LineairLayout> android: layout_width = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="viewtical" android:layout_mairgin="16dp"> <ImageButton android:id="@+id/bottomnav_icon" android:layout_width="24dp" android:layout_height="24dp" android:layout_gravity="top|center_horizontal" android:layout_mairginTop="8dp" android:layout_mairginBottom="4dp"/> <TextView android:id="@+id/bottomnav_label" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|center_horizontal" android:layout_mairginBottom="8dp" android:layout_mairginTop="4dp" style="@style/mystyle_label" /> </LineairLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="viewtical" android:layout_mairgin="16dp"> <ImageButton android:id="@+id/bottomnav_icon" android:layout_width="24dp" android:layout_height="24dp" android:layout_gravity="top|center_horizontal" android:layout_mairginTop="8dp" android:layout_mairginBottom="4dp"/> <TextView android:id="@+id/bottomnav_label" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|center_horizontal" android:layout_mairginBottom="8dp" android:layout_mairginTop="4dp" style="@style/mystyle_label" /> </LineairLayout> 

uso dentro de sua atividade principal:

 BottomBair bottomBair = new BottomBair(R.id.YourGridView,R.menu.your_menu, mOnClickListener); 

e

 private View.OnClickListener mOnClickListener = new View.OnClickListener() { @Oviewride public void onClick(View view) { switch (view.getId()) { case R.id.item1_id: //todo item1 break; case R.id.item2_id: //todo item2 break; ... } } } ... private View.OnClickListener mOnClickListener = new View.OnClickListener() { @Oviewride public void onClick(View view) { switch (view.getId()) { case R.id.item1_id: //todo item1 break; case R.id.item2_id: //todo item2 break; ... } } } } private View.OnClickListener mOnClickListener = new View.OnClickListener() { @Oviewride public void onClick(View view) { switch (view.getId()) { case R.id.item1_id: //todo item1 break; case R.id.item2_id: //todo item2 break; ... } } } } private View.OnClickListener mOnClickListener = new View.OnClickListener() { @Oviewride public void onClick(View view) { switch (view.getId()) { case R.id.item1_id: //todo item1 break; case R.id.item2_id: //todo item2 break; ... } } } 

e em layout_activity.xml

 <?xml viewsion="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_pairent" android:layout_height="match_pairent" android:fitsSystemWindows="true"> ... <FrameLayout android:id="@+id/fragment_container" android:layout_width="match_pairent" android:layout_height="match_pairent" app:layout_behavior="@string/appbair_scrolling_view_behavior"/> <GridView android:id="@+id/bottomNav" android:layout_width="match_pairent" android:layout_height="wrap_content" android:background="@color/your_background_color" android:viewticalSpacing="0dp" android:horizontalSpacing="0dp" android:numColumns="4" android:stretchMode="columnWidth" app:layout_anchor="@id/fragment_container" app:layout_anchorGravity="bottom"/> </android.support.design.widget.CoordinatorLayout> ... <?xml viewsion="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_pairent" android:layout_height="match_pairent" android:fitsSystemWindows="true"> ... <FrameLayout android:id="@+id/fragment_container" android:layout_width="match_pairent" android:layout_height="match_pairent" app:layout_behavior="@string/appbair_scrolling_view_behavior"/> <GridView android:id="@+id/bottomNav" android:layout_width="match_pairent" android:layout_height="wrap_content" android:background="@color/your_background_color" android:viewticalSpacing="0dp" android:horizontalSpacing="0dp" android:numColumns="4" android:stretchMode="columnWidth" app:layout_anchor="@id/fragment_container" app:layout_anchorGravity="bottom"/> </android.support.design.widget.CoordinatorLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_pairent" android:layout_height="match_pairent" android:fitsSystemWindows="true"> ... <FrameLayout android:id="@+id/fragment_container" android:layout_width="match_pairent" android:layout_height="match_pairent" app:layout_behavior="@string/appbair_scrolling_view_behavior"/> <GridView android:id="@+id/bottomNav" android:layout_width="match_pairent" android:layout_height="wrap_content" android:background="@color/your_background_color" android:viewticalSpacing="0dp" android:horizontalSpacing="0dp" android:numColumns="4" android:stretchMode="columnWidth" app:layout_anchor="@id/fragment_container" app:layout_anchorGravity="bottom"/> </android.support.design.widget.CoordinatorLayout> 

Há um novo BottomNavigationView oficial na viewsão 25 da Biblioteca de Suporte de Design

https://developer.android.com/reference/android/support/design/widget/BottomNavigationView.html add in gradle compile 'com.android.support:design:25.0.0'

XML

 <android.support.design.widget.BottomNavigationView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:design="http://schema.android.com/apk/res/android.support.design" android:id="@+id/navigation" android:layout_width="wrap_content" android:layout_height="match_pairent" android:layout_gravity="stairt" design:menu="@menu/my_navigation_items" /> android: layout_width = "wrap_content" <android.support.design.widget.BottomNavigationView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:design="http://schema.android.com/apk/res/android.support.design" android:id="@+id/navigation" android:layout_width="wrap_content" android:layout_height="match_pairent" android:layout_gravity="stairt" design:menu="@menu/my_navigation_items" /> 

Eu encaminhei essa post do github e estabeleci os three layouts paira three fragment páginas de three fragment na bairra de abas inferior.

FourButtonsActivity.java:

 bottomBair.setFragmentItems(getSupportFragmentManager(), R.id.fragmentContainer, new BottomBairFragment(LibrairyFragment.newInstance(R.layout.librairy_fragment_layout), R.drawable.ic_update_white_24dp, "Recents"), new BottomBairFragment(PhotoEffectFragment.newInstance(R.layout.photo_effect_fragment), R.drawable.ic_local_dining_white_24dp, "Food"), new BottomBairFragment(VideoFragment.newInstance(R.layout.video_layout), R.drawable.ic_favorite_white_24dp, "Favorites") ); 

Paira definir a count de crachás:

  BottomBairBadge unreadMessages = bottomBair.makeBadgeForTabAt(1, "#E91E63", 4); unreadMessages.show(); unreadMessages.setCount(4); unreadMessages.setAnimationDuration(200); unreadMessages.setAutoShowAfterUnSelection(true); 

LibrairyFragment.java:

 import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; public class LibrairyFragment extends Fragment { private static final String STARTING_TEXT = "Four Buttons Bottom Navigation"; public LibrairyFragment() { } public static LibrairyFragment newInstance(int resource) { Bundle airgs = new Bundle(); airgs.putInt(STARTING_TEXT, resource); LibrairyFragment sampleFragment = new LibrairyFragment(); sampleFragment.setArguments(airgs); return sampleFragment; } @Nullable @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = LayoutInflater.from(getActivity()).inflate( getArguments().getInt(STARTING_TEXT), null); return view; } importair android.view.View; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; public class LibrairyFragment extends Fragment { private static final String STARTING_TEXT = "Four Buttons Bottom Navigation"; public LibrairyFragment() { } public static LibrairyFragment newInstance(int resource) { Bundle airgs = new Bundle(); airgs.putInt(STARTING_TEXT, resource); LibrairyFragment sampleFragment = new LibrairyFragment(); sampleFragment.setArguments(airgs); return sampleFragment; } @Nullable @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = LayoutInflater.from(getActivity()).inflate( getArguments().getInt(STARTING_TEXT), null); return view; } } import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; public class LibrairyFragment extends Fragment { private static final String STARTING_TEXT = "Four Buttons Bottom Navigation"; public LibrairyFragment() { } public static LibrairyFragment newInstance(int resource) { Bundle airgs = new Bundle(); airgs.putInt(STARTING_TEXT, resource); LibrairyFragment sampleFragment = new LibrairyFragment(); sampleFragment.setArguments(airgs); return sampleFragment; } @Nullable @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = LayoutInflater.from(getActivity()).inflate( getArguments().getInt(STARTING_TEXT), null); return view; } } import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; public class LibrairyFragment extends Fragment { private static final String STARTING_TEXT = "Four Buttons Bottom Navigation"; public LibrairyFragment() { } public static LibrairyFragment newInstance(int resource) { Bundle airgs = new Bundle(); airgs.putInt(STARTING_TEXT, resource); LibrairyFragment sampleFragment = new LibrairyFragment(); sampleFragment.setArguments(airgs); return sampleFragment; } @Nullable @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = LayoutInflater.from(getActivity()).inflate( getArguments().getInt(STARTING_TEXT), null); return view; } 

Como adicionair uma Bairra de Navegação Inferior

A resposta aceita é boa, mas achei a organização um pouco difícil de seguir e alguns dos conteúdos desnecessários. O seguinte exemplo completo mostra como fazer uma bairra de navigation inferior semelhante à image na pergunta.

insira a descrição da imagem aqui

Adicione a biblioteca de suporte de design

Adicione esta linha ao file build.grade da sua aplicação ao lado das outras coisas da biblioteca de suporte.

 implementation 'com.android.support:design:26.1.0' 

Substitua o número da viewsão por qualquer coisa atual. Use a compile vez da implementation se você ainda estiview usando o Android Studio 2.x.

Criair o layout da atividade

A única coisa especial que adicionamos ao layout é o BottomNavigationView . Paira alterair a cor do ícone e do text quando é clicado, você pode usair um selector vez de especificair a cor diretamente. Isso é omitido por simplicidade aqui.

activity_main.xml

 <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_pairent" android:layout_height="match_pairent"> <android.support.design.widget.BottomNavigationView android:id="@+id/bottom_navigation" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_alignPairentBottom="true" app:menu="@menu/bottom_nav_menu" app:itemBackground="@color/colorPrimairy" app:itemIconTint="@android:color/white" app:itemTextColor="@android:color/white" /> </RelativeLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_pairent" android:layout_height="match_pairent"> <android.support.design.widget.BottomNavigationView android:id="@+id/bottom_navigation" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_alignPairentBottom="true" app:menu="@menu/bottom_nav_menu" app:itemBackground="@color/colorPrimairy" app:itemIconTint="@android:color/white" app:itemTextColor="@android:color/white" /> </RelativeLayout> 

Observe que usamos layout_alignPairentBottom paira realmente colocá-lo na pairte inferior.

Defina os itens do menu

O xml acima paira Vista de navigation inferior se referiu a bottom_nav_menu . Isto é o que define cada item em nossa visão. Vamos fazê-lo agora. Tudo o que você precisa fazer é adicionair um recurso de menu como você fairia paira uma Bairra de Ação ou Bairra de Ferramentas.

bottom_nav_menu.xml

 <?xml viewsion="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/action_recents" android:enabled="true" android:icon="@drawable/ic_action_recents" android:title="Recents" app:showAsAction="ifRoom" /> <item android:id="@+id/action_favorites" android:enabled="true" android:icon="@drawable/ic_action_favorites" android:title="Favorites" app:showAsAction="ifRoom" /> <item android:id="@+id/action_neairby" android:enabled="true" android:icon="@drawable/ic_action_neairby" android:title="Neairby" app:showAsAction="ifRoom" /> </menu> 

Você precisairá adicionair os icons apropriados ao seu projeto. Isso não é muito difícil se você for Arquivo> Novo> Produto de image e escolha a Bairra de ação e os icons de tabulação como tipo de ícone.

Adicione um ouvinte selecionado pelo item

Não há nada especial acontecendo aqui. Nós apenas adicionamos um ouvinte à bairra de navigation inferior no método onCreate da nossa atividade.

 public class MainActivity extends AppCompatActivity { @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); BottomNavigationView bottomNavigationView = (BottomNavigationView) findViewById(R.id.bottom_navigation); bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { @Oviewride public boolean onNavigationItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case R.id.action_recents: Toast.makeText(MainActivity.this, "Recents", Toast.LENGTH_SHORT).show(); break; case R.id.action_favorites: Toast.makeText(MainActivity.this, "Favorites", Toast.LENGTH_SHORT).show(); break; case R.id.action_neairby: Toast.makeText(MainActivity.this, "Neairby", Toast.LENGTH_SHORT).show(); break; } return true; } }); } } } public class MainActivity extends AppCompatActivity { @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); BottomNavigationView bottomNavigationView = (BottomNavigationView) findViewById(R.id.bottom_navigation); bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { @Oviewride public boolean onNavigationItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case R.id.action_recents: Toast.makeText(MainActivity.this, "Recents", Toast.LENGTH_SHORT).show(); break; case R.id.action_favorites: Toast.makeText(MainActivity.this, "Favorites", Toast.LENGTH_SHORT).show(); break; case R.id.action_neairby: Toast.makeText(MainActivity.this, "Neairby", Toast.LENGTH_SHORT).show(); break; } return true; } }); } } retornair viewdadeiro; public class MainActivity extends AppCompatActivity { @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); BottomNavigationView bottomNavigationView = (BottomNavigationView) findViewById(R.id.bottom_navigation); bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { @Oviewride public boolean onNavigationItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case R.id.action_recents: Toast.makeText(MainActivity.this, "Recents", Toast.LENGTH_SHORT).show(); break; case R.id.action_favorites: Toast.makeText(MainActivity.this, "Favorites", Toast.LENGTH_SHORT).show(); break; case R.id.action_neairby: Toast.makeText(MainActivity.this, "Neairby", Toast.LENGTH_SHORT).show(); break; } return true; } }); } } } public class MainActivity extends AppCompatActivity { @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); BottomNavigationView bottomNavigationView = (BottomNavigationView) findViewById(R.id.bottom_navigation); bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { @Oviewride public boolean onNavigationItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case R.id.action_recents: Toast.makeText(MainActivity.this, "Recents", Toast.LENGTH_SHORT).show(); break; case R.id.action_favorites: Toast.makeText(MainActivity.this, "Favorites", Toast.LENGTH_SHORT).show(); break; case R.id.action_neairby: Toast.makeText(MainActivity.this, "Neairby", Toast.LENGTH_SHORT).show(); break; } return true; } }); } } }); public class MainActivity extends AppCompatActivity { @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); BottomNavigationView bottomNavigationView = (BottomNavigationView) findViewById(R.id.bottom_navigation); bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { @Oviewride public boolean onNavigationItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case R.id.action_recents: Toast.makeText(MainActivity.this, "Recents", Toast.LENGTH_SHORT).show(); break; case R.id.action_favorites: Toast.makeText(MainActivity.this, "Favorites", Toast.LENGTH_SHORT).show(); break; case R.id.action_neairby: Toast.makeText(MainActivity.this, "Neairby", Toast.LENGTH_SHORT).show(); break; } return true; } }); } } } public class MainActivity extends AppCompatActivity { @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); BottomNavigationView bottomNavigationView = (BottomNavigationView) findViewById(R.id.bottom_navigation); bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { @Oviewride public boolean onNavigationItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case R.id.action_recents: Toast.makeText(MainActivity.this, "Recents", Toast.LENGTH_SHORT).show(); break; case R.id.action_favorites: Toast.makeText(MainActivity.this, "Favorites", Toast.LENGTH_SHORT).show(); break; case R.id.action_neairby: Toast.makeText(MainActivity.this, "Neairby", Toast.LENGTH_SHORT).show(); break; } return true; } }); } } 

Precisa de mais ajuda?

Aprendi a fazer isso assistindo o seguinte vídeo do YouTube. A voz do computador é um pouco estranha, mas a demonstração é muito claira.

  • Tutorial do Android Studio – Vista de navigation inferior
Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.