Search code examples
androidxamarinxamarin.androiduinavigationbar

how to edit a default navigation bar


So a noob question: I started a project with a navigation bar in Xamarin and I just want to change the default icons and change names under them in accordance with my app. Can I do that in the constructor view? The buttons themselves already do what I want them to do but I just want to change their appearance. pic activity_main.xml just in case:

<RelativeLayout 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:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <RelativeLayout
        android:id="@+id/containerTwo"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <WebView
        android:id="@+id/webview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@id/navigation" />
        <com.google.android.material.bottomnavigation.BottomNavigationView
            android:id="@+id/navigation"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginEnd="0dp"
            android:layout_marginStart="0dp"
            android:background="?android:attr/windowBackground"
            android:layout_alignParentBottom="true"
            app:menu="@menu/navigation"
            android:accessibilityHeading="true"
        />
    
        </RelativeLayout>

</RelativeLayout>

Solution

  • Okay, I got it. What I managed to do:

    • Used this article
    • Installed Xamarin.Android.Support.Design
    • Downloaded desired icons from Asset Studio
    • Unpacked zip file with icons and placed all of the "drawable" folders in Resources\drawable
    • changed android:icon parameter in navigaton.xml to one of the downloaded icon names

    NOTE: sometimes preview gets messed up, for example it might size icons in different scales but when you emulate the build or execute it on a real phone everything looks fine.