简体   繁体   中英

How to import Material Design Standard Icons into a Visual Studio Xamarin Project

We have developed an Android App based on old Holo.Light Theme which is using the Android Standard Icons from Library Version 2013/11/06. For usage of the icons I always copied the ones I need manually from Standard Library into my Visual Studio/Xamarin folders under:

/drawable-hdpi

/drawable-mdpi

/drawable-xhdpi

/drawable-xxhdpi

Now I have changed the Default Theme to Android Material Design and I also want to exchange the old icons with the ones from https://github.com/google/material-design-icons/ My plan was just to copy the new material design icons, which I need from the new standard library, to my project folders to exchange the old ones. OK, the names are different for similar icons, but appropriate icons can be found.

But in the new material-design-icons library I have in each folder now, for each icon a set of different sizes. In old one I had always just one per folder, eg for material design icon ic_edit_black_xx I have in each library folder now …

/drawable-mdpi/

  • ic_edit_black_18dp.png
  • ic_edit_black_24dp.png
  • ic_edit_black_36dp.png
  • ic_edit_black_48dp.png

/drawable-hdpi/

  • ic_edit_black_18dp.png
  • ic_edit_black_24dp.png
  • ic_edit_black_36dp.png
  • ic_edit_black_48dp.png

Also there is now the size part of the icon name.

So how is the procedure now?

1.) Do I always need to copy all the four icon sizes to each folder? (doesn't make sense to me)

2.) Will the name-extension with the size remain, or do I have to remove it? Or does Android need the extension for the size selection? What I have to implement in my c# code and in my xml code if I want the reference this icon? Just "ic_edit_black" ??

I could not find information in the web telling me how I should handle that with Visual Studio/Xamarin.

Would be great if someone could explain to me or send me a good link to an explanation.

Thanks in Advance and Best Regards

Marc

1.) Do I always need to copy all the four icon sizes to each folder? (doesn't make sense to me)

This is simply a scaling ratio(ie 18, 24, 36, 48) to support smaller/larger screens based on dpi. Most people can get away with just 24dp for toolbar/notification icons and 36dp for icons on other items like buttons. Otherwise you can calculate these out via the following values:

ldpi = 0.75 - 18x18

mdpi = 1.0 - 24x24 (baseline)

hdpi = 1.5 - 36x36

xhdpi = 2.0 - 48x48

xxhdpi = 3.0

xxxhdpi = 4.0

To answer the question directly, the answer is No you do not. You can pick which corresponding size you want. However it is a good idea to keep these around for different sized devices.

2.) Will the name-extension with the size remain, or do I have to remove it? Or does Android need the extension for the size selection? What I have to implement in my c# code and in my xml code if I want the reference this icon? Just "ic_edit_black" ??

I would keep the size inside your icon name so you can use it throughout your application for different purposes(Such as display size). Android will already check for the proper dpi level to be used via a display bucket.

https://developer.android.com/training/multiscreen/screensizes.html

You will need to specify the exact resource name as it appears in your project. If you keep the size extension in the name, use that. If you decide you only need 1 size for each icon, you can rename it(use the baseline).

https://developer.android.com/training/multiscreen/screendensities.html

Hi Just try this amazing extension

This plugin helps you to add material design icons to your Android, iOS or UWP project

Features

  • Add icons from google public icons repo
  • Support for Xamarin.Android project
  • Support for Xamarin.iOS project
  • Support for UWP project

Good Luck !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM