Android 项目使用矢量图
2016-12-08 11:36
134 查看
1、依赖库和配置:
2、创建矢量图
右键 res 目录创建 Vector Asset 资源
3、使用矢量图
只能通过代码设置 View 的背景
4、使用美工的svg
使用 Android Studio 的 SVG 工具将一个 SVG 文件生成 VectorDrawable 资源文件
参考:
http://www.voidcn.com/blog/qq_23547831/article/p-6223846.html
http://blog.csdn.net/aaa111/article/details/51503199
http://www.jianshu.com/p/313912ff2f37
compile 'com.android.support:support-vector-drawable:25.0.1' compile 'com.android.support:appcompat-v7:25.0.1'
android { defaultConfig { vectorDrawables.useSupportLibrary = true } }
2、创建矢量图
右键 res 目录创建 Vector Asset 资源
3、使用矢量图
xmlns:app="http://schemas.android.com/apk/res-auto" <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" app:srcCompat="@drawable/ic_android_black_24dp" />
只能通过代码设置 View 的背景
Resources resources = context.getResources(Resources, int, Theme); Theme theme = context.getTheme(); Drawable drawable = VectorDrawableCompat.create(resources, R.drawable.vector_drawable, theme); view.setBackground(drawable);
4、使用美工的svg
使用 Android Studio 的 SVG 工具将一个 SVG 文件生成 VectorDrawable 资源文件
参考:
http://www.voidcn.com/blog/qq_23547831/article/p-6223846.html
http://blog.csdn.net/aaa111/article/details/51503199
http://www.jianshu.com/p/313912ff2f37
相关文章推荐
- 将.ai文件矢量图转化为.xml文件并在Android项目中使用
- Android 小项目之--使用【AudioManager】类控制音量 推荐
- 使用Tortoise SVN版本控制Eclipse工作区的Android项目时编译错误(zz)
- Android 小项目之--SQLite 使用法门
- Android使用ant对项目进行编译签名优化打包
- Android使用ant对项目进行编译签名优化打包
- Android 小项目之--SQLite 使用法门 (附源码)
- Android 使用JNI的项目通过Proguard混淆后程序异常的问题
- Android使用ant对项目进行编译签名优化打包
- Android 小项目之--使用【AudioManager】类控制音量
- Android 程式开发:(九)使用活动栏 —— 9.3自定义ActionBar项目和程序图标
- 使用SVN创建Android项目时发生空包丢失(吐槽)
- 使用Tortoise SVN版本控制Android项目in eclipse的注意事项
- 使用Tortoise SVN版本控制Eclipse工作区的Android项目
- Android使用NDK开发项目时的一些问题
- Android 小项目之--使用【AudioManager】类控制音量
- 使用Tortoise SVN版本控制Android项目in eclipse的注意事项
- Android新浪微博-项目整理总结 二[使用WebView获取OAuth验证码]
- Android 小项目之--SQLite 使用法门
- Android_Listview中使用线程实现无限加载更多项目的功能