我刚刚完成了我的第一个应用程序,虽然它适用于我的nexus 5(API 21),当我尝试在较旧的API中测试它时,它会在启动屏幕(实现按钮)后崩溃,我使用AppCompat库我的风格和清单设置得当。请查找我的XML文件的附加部分以及我的stacktrace。任何关于什么是有缺陷的嘘声或建议都非常感谢!非常感谢,提前! PS.I试图删除按钮,它似乎工作。任何提示?
layout.xml
<Button
android:id="@+id/finalize"
android:layout_width="160dp"
android:layout_height="50dp"
android:background="@drawable/finalize_button"
android:text="@string/finalize_workout"
android:textColor="#FFFFFF"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="40dp"
android:visibility="gone"/>
<Button
android:id="@+id/feedbackButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/myrect2"
android:text="@string/feedback_button"
android:textColor="@color/colorPrimaryDark"
style="?android:attr/borderlessButtonStyle"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="56dp"
android:layout_marginRight="26dp"
android:textSize="12sp"/>
finalize_button.xml drawable
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/colorPrimary"/>
<corners android:radius="6dp"/>
</shape>
</item>
<item android:drawable="?android:selectableItemBackground"/>
堆栈跟踪
11-16 02:52:15.060 1844-1844/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.thanoschatz.quench/com.thanoschatz.quench.NewWorkoutActivity}: android.view.InflateException: Binary XML file line #53: Error inflating class android.widget.Button
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #53: Error inflating class android.widget.Button
Caused by: java.lang.reflect.InvocationTargetException
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/finalize_button.xml from drawable resource ID #0x7f02003b
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #9: <item> tag requires a 'drawable' attribute or child tag defining a drawable