2016-06-28 106 views
0

我用选择的复选框,它的工作原理,但它会导致预棒棒糖版本如何在选择器中使用svgs用于pre lolipop版本?

<selector xmlns:android="..."> 
    <item android:state_checked="true" 
     android:drawable="@drawable/checked_icon" /> 
    <item android:drawable="@drawable/icon" /> 
</selector> 




<CheckBox 
android:button="@drawable/terms_checkbox"/> 

它会导致resourcNotFoundexception,如何解决这个问题的问题,有什么解决办法吗?

致命异常:主要 android.view.InflateException:二进制XML文件行#70:错误充气类复选框

 at dalvik.system.NativeStart.main(Native Method) 
                    Caused by: android.content.res.Resources$NotFoundException: File res/drawable/terms_service1.xml from drawable resource ID #0x7f020121 
                     at android.content.res.Resources.loadDrawable(Resources.java:2096) 
                     at android.content.res.TypedArray.getDrawable(TypedArray.java:601) 

                     at android.widget.CompoundButton.<init>(CompoundButton.java:74) 
                     at android.widget.CheckBox.<init>(CheckBox.java:68) 


Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #1: invalid drawable tag vector 
                    at android.graphics.drawable.Drawable.createFromXmlInner(Draw 
+0

对我的作品中的Android 4.3版。 – sJy

+0

我在模拟器上测试android版本4.3.1 android.content.res.Resources $ NotFoundException: –

+0

Gradle中使用的buildToolsVersion是什么? – sJy

回答

0

试试这个。

CheckBox checkBox = (CheckBox) findViewById(R.id.checkBox); 
    Drawable d = AppCompatDrawableManager.get().getDrawable(this, R.drawable.terms_checkbox); 
    checkBox.setButtonDrawable(d); 
相关问题