Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove Icon from Action Bar xamarin

I want to remove my icon from action bar, I'm using a MasterDetail page to create a slider, I'm using the left icon to open the slider, but the right smaller icon sided of "APP Vendas" I want to remove, I tryied everything on C# to easly remove without success. Tryiend tranpatent, RGBA, None, etc, here is my code and Image:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using App5.Menu;
using App5.Categorias;
using App5;
namespace App5
{
    public class MainPage : MasterDetailPage
    {
        public MainPage()
        {
            var menuPage = new MenuPage();
            menuPage.OnMenuTap = (page) =>
            {
                IsPresented = false;
                Detail = new NavigationPage(page);
            };
            Master = menuPage;
            Detail = new NavigationPage(new Resumo())
            {
                BarBackgroundColor = Color.Black,
                Icon = None
            };




        }

    }
}

The right Icon is what I want to remove

like image 796
Fred Vicentin Avatar asked Dec 08 '15 16:12

Fred Vicentin


1 Answers

You need to just add those single line code in MainActivity.cs file in your Android project.

ActionBar.SetIcon(Android.Resource.Color.Transparent);

For Example

using Android.OS;
using Android.Content.PM;

namespace Test.Droid
{

    [Activity(Label = "test", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            global::Xamarin.Forms.Forms.Init(this, bundle);
            ActionBar.SetIcon(Android.Resource.Color.Transparent);
            LoadApplication(new App());

        }
    }
like image 151
Shahabuddin Vansiwala Avatar answered Sep 17 '22 20:09

Shahabuddin Vansiwala