Reynevan
Reynevan

Reputation: 1545

Xamarin.Android Material Design Icons

A bit of context:

I was looking into the Material Design Support Library for Xamarin and found this article about various controls from this library.

I tried to reproduce the Toolbar from the last example (for now I'm not even thinking about implementing the whole hamburger navigation example, just the toolbar with the button). I set it up, created MyTheme with my colors, added the fixes for style-v21 and so on. Everything works well so far, though the <include ... /> node throws a warning that it's not a recognized child for RelativeLayout. Still, it's building correctly so I can deal with it for the most part.

The problem:

Here's where my problem starts:

...
    // Set our view from the "main" layout resource
    SetContentView (Resource.Layout.main_layout);
    var toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
    SetSupportActionBar (toolbar);

    //Enable support action bar to display hamburger
    SupportActionBar.SetHomeAsUpIndicator (Resource.Drawable.ic_menu);
    SupportActionBar.SetDisplayHomeAsUpEnabled (true);
...

With the SupportActionBar set up like that, it doesn't display the button. Also, the ic_menu drawable seems to be missing. In fact, there aren't any that start with ic_, only abc_.

Am I missing something here?

Cheers!

Upvotes: 2

Views: 2863

Answers (1)

yash darak
yash darak

Reputation: 368

Go to https://material.io/icons/ and download menu icon and then add that icon to the drawable folder and then replace ic_menu in your code with the image name.

NOTE: Do not add image extension name like .jpg,.png with image name

Upvotes: 3

Related Questions