Android 个图标 xml
Android icons in xml
我使用预定义的 activity 抽屉,它给了我这样格式的图标:
`<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M4,6H2v14c0,1.1 0.9,2 2,2h14v-2H4V6zm16,-4H8c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2V4c0,-1.1 -0.9,-2 -2,-2zm-8,12.5v-9l6,4.5 -6,4.5z" />
</vector>
`
早些时候我在几个选项中使用了 png 中的图标(用于 lowdp、hdpi 等)。使用这种风格的图标有什么好处?如何以这种方式创建图标?
此致
多米尼克
SVG 的优点:-
- 尺寸更小
- 图像质量好
- 容易变色
- 容易改变尺寸
例如:- 更改宽度 android:width="24dp"
改变颜色android:fillColor="#FF000000"
试试这个方法
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:background="@drawable/ic_launcher"
android:layout_height="match_parent">
</RelativeLayout>
我使用预定义的 activity 抽屉,它给了我这样格式的图标:
`<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M4,6H2v14c0,1.1 0.9,2 2,2h14v-2H4V6zm16,-4H8c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2V4c0,-1.1 -0.9,-2 -2,-2zm-8,12.5v-9l6,4.5 -6,4.5z" />
</vector>
` 早些时候我在几个选项中使用了 png 中的图标(用于 lowdp、hdpi 等)。使用这种风格的图标有什么好处?如何以这种方式创建图标?
此致
多米尼克
SVG 的优点:-
- 尺寸更小
- 图像质量好
- 容易变色
- 容易改变尺寸
例如:- 更改宽度 android:width="24dp"
改变颜色android:fillColor="#FF000000"
试试这个方法
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:background="@drawable/ic_launcher"
android:layout_height="match_parent">
</RelativeLayout>