android - Unable to create a radial gradient -
i'm trying create button radial gradient, everytime load app, crashes.
mylayout.xml:
... <button android:id="@+id/mybutton" android:layout_width="@dimen/btnwidth" android:layout_height="@dimen/btnheight" android:background="@drawable/mybutton" /> ...
mybutton.xml:
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> <gradient android:type="radial" android:startcolor="@color/my_start_color" android:endcolor="@color/my_end_color"/> </shape> </item> </layer-list>
below error log. i'm targeting android sdk 22.
fatal exception: main java.lang.runtimeexception: unable start activity componentinfo{com.my.app/com.my.app.myactivity}: android.view.inflateexception: binary xml file line #324: error inflating class button @ android.app.activitythread.performlaunchactivity(activitythread.java:2339) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2413) @ android.app.activitythread.access$800(activitythread.java:155) @ android.app.activitythread$h.handlemessage(activitythread.java:1317) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:135) @ android.app.activitythread.main(activitythread.java:5343) @ java.lang.reflect.method.invoke(native method) @ java.lang.reflect.method.invoke(method.java:372) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:905) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:700) caused by: android.view.inflateexception: binary xml file line #324: error inflating class button @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:763) @ android.view.layoutinflater.rinflate(layoutinflater.java:806) @ android.view.layoutinflater.inflate(layoutinflater.java:504) @ android.view.layoutinflater.inflate(layoutinflater.java:414) @ com.my.app.ui.myfragment.oncreateview(myfragment.java:183) @ android.support.v4.app.fragment.performcreateview(fragment.java:1789) @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:924) @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1116) @ android.support.v4.app.fragmentmanagerimpl.addfragment(fragmentmanager.java:1218) @ android.support.v4.app.fragmentmanagerimpl.oncreateview(fragmentmanager.java:2170) @ android.support.v4.app.fragmentactivity.oncreateview(fragmentactivity.java:300) @ android.support.v7.app.appcompatdelegateimplv7.callactivityoncreateview(appcompatdelegateimplv7.java:816) @ android.support.v7.app.appcompatdelegateimplv11.callactivityoncreateview(appcompatdelegateimplv11.java:72) @ android.support.v7.app.appcompatdelegateimplv7.oncreateview(appcompatdelegateimplv7.java:804) @ android.support.v4.view.layoutinflatercompathc$factorywrapperhc.oncreateview(layoutinflatercompathc.java:44) @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:725) @ android.view.layoutinflater.rinflate(layoutinflater.java:806) @ android.view.layoutinflater.rinflate(layoutinflater.java:809) @ android.view.layoutinflater.inflate(layoutinflater.java:504) @ android.view.layoutinflater.inflate(layoutinflater.java:414) @ android.view.layoutinflater.inflate(layoutinflater.java:365) @ android.support.v7.app.appcompatdelegateimplv7.setcontentview(appcompatdelegateimplv7.java:249) @ android.support.v7.app.appcompatactivity.setcontentview(appcompatactivity.java:106) @ com.my.app.myactivity.oncreate(myactivity.java:1033) @ android.app.activity.performcreate(activity.java:6010) @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1129) @ android.app.activitythread.performlaunchactivity(activitythread.java:2292) ... 10 more caused by: android.content.res.resources$notfoundexception: file res/drawable-hdpi/mybutton.xml drawable resource id #0x7f02008a @ android.content.res.resources.loaddrawableforcookie(resources.java:2482) @ android.content.res.resources.loaddrawable(resources.java:2384) @ android.content.res.typedarray.getdrawable(typedarray.java:749) @ android.view.view.(view.java:3742) @ android.widget.textview.(textview.java:637) @ android.widget.button.(button.java:111) @ android.widget.button.(button.java:107) @ android.support.v7.widget.appcompatbutton.(appcompatbutton.java:60) @ android.support.v7.widget.appcompatbutton.(appcompatbutton.java:56) @ android.support.v7.internal.app.appcompatviewinflater.createview
you need gradient radius:
<gradient android:type="radial" android:gradientradius="40" android:startcolor="@color/my_start_color" android:endcolor="@color/my_end_color"/>
Comments
Post a Comment