[英]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.