简体   繁体   English

如何在Android中使用XML中的Material Design图标?

[英]How can I use the Material Design icons in XML in Android?

I managed to clone the git repository of Material Design icons, but now I'm struggling with how to use it. 我设法克隆了Material Design图标的git存储库,但现在我正在努力使用它。

I want to use the icon resources in the XML files, in the XML attributes like android:icon="@drawable/*** . 我想在XML文件中使用图标资源,例如android:icon="@drawable/***

so I searched quite many articles and none of them seems to be clear so far. 所以我搜索了很多文章,到目前为止似乎都没有。 Can someone explain? 谁能解释一下?

You don't need to clone the repository to do this. 您无需克隆存储库即可执行此操作。 If you're using an up to date version of Android Studio you can import the individual icons you need directly. 如果您使用的是最新版本的Android Studio,则可以直接导入所需的各个图标。

Right-click on your drawable folder and in the menu go to New > Vector Asset. 右键单击您的drawable文件夹,然后在菜单中转到New> Vector Asset。 From there the default option is to select any of the Material icons to use, or you have the option to use your own SVG files. 从那里,默认选项是选择要使用的任何材质图标,或者您可以选择使用自己的SVG文件。

In your project directory there's a drawable folder, the path should be: /app/src/main/res/drawable your icons have to be put in that folder in order to be used with @drawable/ command in XML. 在你的项目目录中有一个drawable文件夹,路径应该是:/ app / src / main / res / drawable你的图标必须放在那个文件夹中,以便与XML中的@drawable/命令一起使用。

Here a similar question, and here the link to the android drawable importer 这里有一个类似的问题, 这里是android drawable导入器的链接

你需要将drawables导入你的项目 - android drawable importer插件对此非常有用

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

相关问题 如何在 Android Studio 中使用带轮廓的 Material 图标? - How can I use outlined Material icons in Android Studio? Android如何在布局文件中使用材质设计图标 - Android how to use material design icons in layout files 如何获得创辉材料设计图标以在 Android 应用程序中使用 - How to get colorfull material design icons to use in android app 在XML中使用材质图标 - Use Material Icons in XML 我如何在Android XML设计中使用多种形状 - How can i use multiple shapes in android xml design android工作室和材料设计图标 - android studio and material design icons 我应该如何使用材料设计更改顶部工具栏中图标和标题的颜色? -NoActionBar 主题 - Android 材料设计 - How should I change the color of the icons and title in the top toolbar using material design? -NoActionBar theme - Android Material Design 如何在 Android 通知中将 Material Icons 用作 LargeIcon? - How to use Material Icons as LargeIcon in Android notifications? 如何在android上启动android材质设计动画的活动 - How can I start activity with android material design animation on android 如何更改“材料设计”图标的颜色以适合特定主题? - How can the colour of the Material Design icons be changed to suit a specific theme?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM