Skip to main content

Xamarin Bottom Navigation

· 3 min read

The problem

The bottom navigation is a very simple and easy template from Android Studio, the porting took 15 minutes at most and the result is quite appealing.

The solution

Ported from the Android Studio template, quick and easy the Navigation Drawer was way harder than this.


All the code is available at the xamarin-templates repo

The fun

My IDE is VS2017 and I created a "Blank App (Android)" project. I decided for:

  • Minimum Android version: Android 5.0 (API Level 21 - Lollipop)
  • Target Framework: Android 7.1 (Nougat)
  • Target Android version: "Use compile using SDK version"

All the NuGet packages installed, be aware that I only choose a couple of them, the other are dependencies.

<package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="" targetFramework="monoandroid71" />
<package id="Xamarin.Android.Support.Annotations" version="" targetFramework="monoandroid71" />
<package id="Xamarin.Android.Support.Compat" version="" targetFramework="monoandroid71" />
<package id="Xamarin.Android.Support.Core.UI" version="" targetFramework="monoandroid71" />
<package id="Xamarin.Android.Support.Core.Utils" version="" targetFramework="monoandroid71" />
<package id="Xamarin.Android.Support.Design" version="" targetFramework="monoandroid71" />
<package id="Xamarin.Android.Support.Fragment" version="" targetFramework="monoandroid71" />
<package id="Xamarin.Android.Support.Media.Compat" version="" targetFramework="monoandroid71" />
<package id="Xamarin.Android.Support.Transition" version="" targetFramework="monoandroid71" />
<package id="Xamarin.Android.Support.v7.AppCompat" version="" targetFramework="monoandroid71" />
<package id="Xamarin.Android.Support.v7.RecyclerView" version="" targetFramework="monoandroid71" />
<package id="Xamarin.Android.Support.Vector.Drawable" version="" targetFramework="monoandroid71" />

TIP Always look at the Android Manifest for the theme of the app, in Xamarin I opted for the Theme Attribute on the Activity. Don't know if there are other options.

TIP There are several resources to copy in order to make the project work. Look at the source code for the details.

The java source code

import android.os.Bundle;
import android.view.MenuItem;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

private TextView mTextMessage;

private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
= new BottomNavigationView.OnNavigationItemSelectedListener() {

public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
return true;
return true;
return true;
return false;


protected void onCreate(Bundle savedInstanceState) {

mTextMessage = (TextView) findViewById(;
BottomNavigationView navigation = (BottomNavigationView) findViewById(;


The C# version, I think that the C# properties give a better readability to the code.

using Android.App;
using Android.Widget;
using Android.OS;
using Android.Support.V7.App;
using Android.Support.Design.Widget;
using Android.Views;

namespace Xamarin.BottomNavigation
[Activity(Label = "Xamarin.BottomNavigation", MainLauncher = true, Theme = "@style/AppTheme")]
public class MainActivity : AppCompatActivity, BottomNavigationView.IOnNavigationItemSelectedListener
private TextView _textMessage;

public bool OnNavigationItemSelected(IMenuItem item)
switch (item.ItemId)
case Resource.Id.navigation_home:
_textMessage.Text = GetString(Resource.String.title_home);
return true;
case Resource.Id.navigation_dashboard:
_textMessage.Text = GetString(Resource.String.title_dashboard);
return true;
case Resource.Id.navigation_notifications:
_textMessage.Text = GetString(Resource.String.title_notifications);
return true;
return false;

protected override void OnCreate(Bundle savedInstanceState)


_textMessage = FindViewById<TextView>(Resource.Id.message);

var navigation = FindViewById<BottomNavigationView>(Resource.Id.navigation);


That's it :)