0
votes

I trying to add a navigation title icon to my app in one of the page and the code that i have used is:

For iOS:

NavigationPage.SetTitleIcon(this, "icon.png");

For Android in the ToolBar.axml I have added a ImageView as shown below:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/colorPrimary"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    android:popupTheme="@style/ThemeOverlay.AppCompat.Light">

    <ImageView
        android:id="@+id/titleicon"
        android:src="@drawable/UstNameIcon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</android.support.v7.widget.Toolbar>

The issue is that, I want my Navigtion icon to get disabled in my next Page and put a title instead of icon.

For that, I tried

For iOS:

NavigationPage.SetTitleIcon(this, null);


NavigationPage.Title="Title";

For Android, How can i achieve the change of Navigation title?

2
Did my solution work for you ?Karol Gasienica
Hi @Anoop, did you find a solution?Gold.strike

2 Answers

0
votes

In MainActivity.cs

[Activity (Label = "Todo.Android.Android", MainLauncher = true, Icon="@android:color/transparent")]

For Title, you can set Title property in xaml or c#

0
votes

To change text you just simple need to find that element by id, and set up a title:

var toolbar = 
    FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); // it may be simplifed
    SetSupportActionBar(toolbar);
    toolbar.Title = "title";

And image is under toolbar.Logo, so you can just try:

toolbar.Logo = null;

If you have some data in resources which you want to put in, you can use also:

toolbar.SetTitle();
toolbar.SetLogo();