如何使用xml定义创建铅笔图标?

时间:2019-02-11 11:07:49

标签: android xml drawable xml-drawable

我正在尝试使用线条(xml定义)创建铅笔图标。但没有得到确切的形状。

2 个答案:

答案 0 :(得分:4)

您可以使用Android Studio本身的铅笔图标,依次为File->New->Vector Assetclick on clip art icon,然后搜索您的特定图片。您还可以通过其XML更改其颜色。

或者您可以从https://www.flaticon.com/下载SVG图像,然后选择所需的图像。在Android Studio中使用后,您还可以从XML更改其颜色。

用于矢量可绘制铅笔图标的XML示例。

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="24.0"
    android:viewportHeight="24.0">
<path
    android:fillColor="#FF000000"
    android:pathData="M3,17.25V21h3.75L17.81,9.94l-3.75,-3.75L3,17.25zM20.71,7.04c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.39,-0.39 -1.02,-0.39 -1.41,0l-1.83,1.83 3.75,3.75 1.83,-1.83z"/>

答案 1 :(得分:1)

如果要使用Vector Drawable,请尝试使用以下代码绘制drawable.xml

myInput