简体   繁体   English

如何将材质设计标准图标导入Visual Studio Xamarin项目

[英]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. 我们开发了一个基于旧Holo.Light主题的Android应用程序,它使用了来自图书馆版本2013/11/06的Android标准图标。 For usage of the icons I always copied the ones I need manually from Standard Library into my Visual Studio/Xamarin folders under: 对于图标的使用,我总是将我需要手动从标准库复制到我的Visual Studio / Xamarin文件夹中:

/drawable-hdpi /提拉 - 华电国际

/drawable-mdpi /绘制-MDPI

/drawable-xhdpi /绘制-xhdpi

/drawable-xxhdpi /绘制-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. 现在我已将默认主题更改为Android Material Design,我还想将旧图标与https://github.com/google/material-design-icons/中的图标进行交换。我的计划只是复制新材料设计我需要从新标准库到我的项目文件夹来交换旧的图标。 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 … 在旧版本中,我每个文件夹只有一个,例如我在每个库文件夹中的材料设计图标ic_edit_black_xx ...

/drawable-mdpi/ /抽拉-MDPI /

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

/drawable-hdpi/ /抽拉-HDPI /

  • ic_edit_black_18dp.png ic_edit_black_18dp.png
  • ic_edit_black_24dp.png ic_edit_black_24dp.png
  • ic_edit_black_36dp.png ic_edit_black_36dp.png
  • ic_edit_black_48dp.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? 1.)我是否总是需要将所有四个图标大小复制到每个文件夹? (doesn't make sense to me) (对我没有意义)

2.) Will the name-extension with the size remain, or do I have to remove it? 2.)大小的名称扩展是否仍然存在,或者我是否必须将其删除? Or does Android need the extension for the size selection? 或Android是否需要扩展大小选择? What I have to implement in my c# code and in my xml code if I want the reference this icon? 如果我想要引用这个图标,我必须在我的c#代码和我的xml代码中实现什么? Just "ic_edit_black" ?? 只是“ic_edit_black”??

I could not find information in the web telling me how I should handle that with Visual Studio/Xamarin. 我无法在网络上找到告诉我如何用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? 1.)我是否总是需要将所有四个图标大小复制到每个文件夹? (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. 这只是一个缩放比例(即18,24,36,48),以支持基于dpi的较小/较大屏幕。 Most people can get away with just 24dp for toolbar/notification icons and 36dp for icons on other items like buttons. 对于工具栏/通知图标,大多数人只能使用24dp,而在按钮等其他项目上则可以使用36dp。 Otherwise you can calculate these out via the following values: 否则,您可以通过以下值计算出这些值:

ldpi = 0.75 - 18x18 ldpi = 0.75 - 18x18

mdpi = 1.0 - 24x24 (baseline) mdpi = 1.0 - 24x24(基线)

hdpi = 1.5 - 36x36 hdpi = 1.5 - 36x36

xhdpi = 2.0 - 48x48 xhdpi = 2.0 - 48x48

xxhdpi = 3.0 xxhdpi = 3.0

xxxhdpi = 4.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? 2.)大小的名称扩展是否仍然存在,或者我是否必须将其删除? Or does Android need the extension for the size selection? 或Android是否需要扩展大小选择? What I have to implement in my c# code and in my xml code if I want the reference this icon? 如果我想要引用这个图标,我必须在我的c#代码和我的xml代码中实现什么? Just "ic_edit_black" ?? 只是“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. Android已经检查了通过显示桶使用的正确dpi级别。

https://developer.android.com/training/multiscreen/screensizes.html 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). 如果您确定每个图标只需要1个大小,则可以重命名(使用基线)。

https://developer.android.com/training/multiscreen/screendensities.html 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 此插件可帮助您向Android,iOS或UWP项目添加材料设计图标

Features 特征

  • Add icons from google public icons repo 从谷歌公共图标仓库添加图标
  • Support for Xamarin.Android project 支持Xamarin.Android项目
  • Support for Xamarin.iOS project 支持Xamarin.iOS项目
  • Support for UWP project 支持UWP项目

Good Luck ! 祝好运 !

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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