2017-09-14 65 views
0

以下兩行似乎都會導致應用程序通貨膨脹崩潰。?attr/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) 
+0

你可以嘗試按ctrl +點擊'ATTR/actionBarSize'看看它的初始化? R文件 –

+0

把你的XML文件,所以我們可以看到什麼是錯誤 –

+0

''這個工作適合我..你可能採取了錯誤的佈局... –

回答

0

嘗試

@dimen/abc_action_bar_default_height_material 

,而不是

?android:attr/actionBarSize