在按钮的android选择器使用SVG
it1352
帮助1人
问题说明
我正在使用 svg 作为 ImageView
的图标,它可以使用 app:srcCompat
给出但是当我想将它用于 Buttons
作为对于 api 低于 21 的设备,应用程序因找不到资源而崩溃的选择器
I am using svg for icons for ImageView
it can be given using app:srcCompat
But when i want to use it for Buttons
as selector the app crashes with resource not found exception for devices with api below 21
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/button_enabled" android:state_enabled="true" />
<item android:drawable="@drawable/button_disabled" android:state_enabled="false" />
</selector>
其中 button_enabled 和 button_disabled 都是 svg
Where button_enabled and button_disabled are both svg
正确答案
#1
我有自己的问题的答案.在您的活动中只需添加此静态块
I have the answer to my own question. In your activity just add this static block
static {
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tanhcfkege
系列文章
更多
同类精品
更多
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
希伯来语的空格句子标记化错误
it1352 06-22 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20