?attr / actionBarSize通胀导致崩溃

时间:2017-09-14 09:23:56

标签: android android-actionbar

以下两行似乎都会导致应用程序崩溃。

    android:layout_height="?attr/actionBarSize"
    // or 
    android:layout_height="?android:attr/actionBarSize"

有什么想法吗?我正在尝试创建自己的栏,标准操作栏的默认大小。

以下例外:

FATAL EXCEPTION: main
Process: com...., PID: 30039
java.lang.RuntimeException: Unable to start activity ComponentInfo{com....../com.....}: 
android.view.InflateException: Binary XML file line #9: Failed to resolve attribute at index 1: TypedValue{t=0x2/d=0x7f010071 a=-1}
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2728)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2814)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1527)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6290)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: android.view.InflateException: Binary XML file line #9: Failed to resolve attribute at index 1: TypedValue{t=0x2/d=0x7f010071 a=-1}
Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 1: TypedValue{t=0x2/d=0x7f010071 a=-1}
at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:761)
at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:7039)
at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:7220)
at android.widget.LinearLayout$LayoutParams.<init>(LinearLayout.java:1926)
at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:1824)
at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:1823)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:860)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)

1 个答案:

答案 0 :(得分:1)

尝试

@dimen/abc_action_bar_default_height_material 

而不是

?android:attr/actionBarSize