In this article we are creating a custom control renderer for Xamarin.Forms allowing developers to override the default native rendering of a Xamarin.Forms control with their own platform-specific code.
We have seen many Xamarin related forums having a strong discussion about removing the action bar icon from an Android project in Xamarin.Forms. Many of them suggest making the application icon as transparent by altering the MainActivity.cs in Android project somewhat like the following:
[Activity (Label = "Sample Application", Icon = "@android:color/transparent", MainLauncher = true]
In this condition no one notices that by altering like this they are making the application icon to be transparent. As a result the application will not show an icon when it is installed on a device.
Today we are showing a way to render your page so that you will be able to remove the unwanted action bar icon depending on your needs.
Here I'm going to render the NavigationPage class that manages the navigation and user experience of a stack of other pages.
Create a class named CustomNavigationRenderer inside the Android project that will be a platform-specific implementation that contains code to hide the icon from the action bar.
- using Android.App;
- using Android.Graphics.Drawables;
- using Xamarin.Forms;
- using Xamarin.Forms.Platform.Android;
- using SampleApp;
- using SampleApp.Droid;
- [assembly: ExportRenderer(typeof(NavigationPage), typeof(CustomNavigationRenderer))]
- namespace SampleApp.Droid {
- public class CustomNavigationRenderer: NavigationRenderer {
- protected override void OnElementChanged(ElementChangedEventArgs < NavigationPage > e) {
- base.OnElementChanged(e);
- RemoveAppIconFromActionBar();
- }
- void RemoveAppIconFromActionBar() {
- var actionBar = ((Activity) Context).ActionBar;
- actionBar.SetIcon(new ColorDrawable(Color.Transparent.ToAndroid()));
- }
- }
- }
Now create a subclass of the NavigationPage control that is to be customized.

SubashPosted Aug 23, 2016, 12:41 AM
Nice One
Vaikesh K PPosted Aug 14, 2015, 2:10 AM
Thanks sravanthi varikoti :)
sravanthi varikotiPosted Aug 14, 2015, 2:06 AM
good share
Vaikesh K PPosted Aug 13, 2015, 5:15 AM
Thanks Sibeesh Venu
Sibeesh VenuPosted Aug 13, 2015, 4:29 AM
Nice Share :)
Vaikesh K PPosted Aug 13, 2015, 3:21 AM
Thanks Nilesh Jadav :)
Nilesh JadavPosted Aug 13, 2015, 2:55 AM
Thanks for sharing, nice article
Vaikesh K PPosted Aug 13, 2015, 12:50 AM
Thanks Santhakumar Munuswamy :)
Vaikesh K PPosted Aug 13, 2015, 12:50 AM
Thanks Rakesh Chavda :)
Vaikesh K PPosted Aug 13, 2015, 12:50 AM
Thanks Rajeesh Menoth :)
Santhakumar MunuswamyPosted Aug 12, 2015, 2:52 PM
Good Article. Thanks for sharing
RakeshPosted Aug 12, 2015, 1:16 PM
Good work
Rajeesh MenothPosted Aug 12, 2015, 1:00 PM
Good One