android布局太深导致的 java.lang.StackOverflowError
Posted 疯子FK
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了android布局太深导致的 java.lang.StackOverflowError相关的知识,希望对你有一定的参考价值。
E/androidRuntime( 1900): java.lang.StackOverflowError
E/AndroidRuntime( 1900): at android.graphics.Canvas.drawText(Canvas.java:1269)
E/AndroidRuntime( 1900): at android.text.Layout.draw(Layout.java:337)
E/AndroidRuntime( 1900): at android.widget.TextView.onDraw(TextView.java:4006)
E/AndroidRuntime( 1900): at android.view.View.draw(View.java:6057)
E/AndroidRuntime( 1900): at android.view.ViewGroup.drawChild(ViewGroup.java:1545)
E/AndroidRuntime( 1900): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1281)
E/AndroidRuntime( 1900): at android.view.ViewGroup.drawChild(ViewGroup.java:1543)
E/AndroidRuntime( 1900): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1281)
E/AndroidRuntime( 1900): at android.view.ViewGroup.drawChild(ViewGroup.java:1543)
E/AndroidRuntime( 1900): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1281)
E/AndroidRuntime( 1900): at android.view.View.draw(View.java:6060)
E/AndroidRuntime( 1900): at android.view.View.buildDrawingCache(View.java:5823)
E/AndroidRuntime( 1900): at android.view.View.getDrawingCache(View.java:5661)
E/AndroidRuntime( 1900): at android.view.ViewGroup.drawChild(ViewGroup.java:1481)
E/AndroidRuntime( 1900): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1281)
E/AndroidRuntime( 1900): at android.widget.AbsListView.dispatchDraw(AbsListView.java:1322)
E/AndroidRuntime( 1900): at android.widget.ListView.dispatchDraw(ListView.java:2841)
E/AndroidRuntime( 1900): at android.view.View.draw(View.java:6164)
E/AndroidRuntime( 1900): at android.widget.AbsListView.draw(AbsListView.java:2169)
E/AndroidRuntime( 1900): at android.view.ViewGroup.drawChild(ViewGroup.java:1545)
E/AndroidRuntime( 1900): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1281)
E/AndroidRuntime( 1900): at android.view.ViewGroup.drawChild(ViewGroup.java:1543)
E/AndroidRuntime( 1900): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1281)
E/AndroidRuntime( 1900): at android.view.ViewGroup.drawChild(ViewGroup.java:1543)
E/AndroidRuntime( 1900): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1281)
E/AndroidRuntime( 1900): at android.view.ViewGroup.drawChild(ViewGroup.java:1543)
E/AndroidRuntime( 1900): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1281)
E/AndroidRuntime( 1900): at android.view.ViewGroup.drawChild(ViewGroup.java:1543)
E/AndroidRuntime( 1900): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1281)
E/AndroidRuntime( 1900): at android.view.ViewGroup.drawChild(ViewGroup.java:1543)
E/AndroidRuntime( 1900): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1281)
E/AndroidRuntime( 1900): at android.view.ViewGroup.drawChild(ViewGroup.java:1543)
E/AndroidRuntime( 1900): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1281)
E/AndroidRuntime( 1900): at android.view.ViewGroup.drawChild(ViewGroup.java:1543)
E/AndroidRuntime( 1900): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1281)
E/AndroidRuntime( 1900): at android.view.ViewGroup.drawChild(ViewGroup.java:1543)
E/AndroidRuntime( 1900): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1281)
E/AndroidRuntime( 1900): at android.view.View.draw(View.java:6060)
E/AndroidRuntime( 1900): at android.widget.FrameLayout.draw(FrameLayout.java:352)
E/AndroidRuntime( 1900): at android.view.ViewGroup.drawChild(ViewGroup.java:1545)
E/AndroidRuntime( 1900): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1281)
E/AndroidRuntime( 1900): at android.view.ViewGroup.drawChild(ViewGroup.java:1543)
E/AndroidRuntime( 1900): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1281)
E/AndroidRuntime( 1900): at android.view.View.draw(View.java:6060)
E/AndroidRuntime( 1900): at android.widget.FrameLayout.draw(FrameLayout.java:352)
E/AndroidRuntime( 1900): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2038)
E/AndroidRuntime( 1900): at android.view.ViewRoot.draw(ViewRoot.java:1233)
E/AndroidRuntime( 1900): at android.view.ViewRoot.performTraversals(ViewRoot.java:1042)
E/AndroidRuntime( 1900): at android.view.ViewRoot.handleMessage(ViewRoot.java:1502)
E/AndroidRuntime( 1900): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 1900): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 1900): at android.app.ActivityThread.main(ActivityThread.java:3972)
E/AndroidRuntime( 1900): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1900): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 1900): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/AndroidRuntime( 1900): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:543)
E/AndroidRuntime( 1900): at dalvik.system.NativeStart.main(Native Method)
I/Process ( 833): Sending signal. PID: 1900 SIG: 3
解决方式:减少布局嵌套层数,特别是用到类似tabHost,ViewPager的控件时,要考虑到最底层的 activity 的
contentView的布局,尽量简化,多用RelativeLayout替代LinearLayout
同样再优化列表滑动效率的时候,简化item布局也能带来巨大的体验提升
以上是关于android布局太深导致的 java.lang.StackOverflowError的主要内容,如果未能解决你的问题,请参考以下文章
Android - 更改表列现在会导致程序崩溃。 java.lang.NumberFormatException:无效的int:“T”
Android - 当 minifyEnabled true 导致 java.lang.ExceptionInInitializerError 时,带有混淆 AAR 库的应用程序崩溃
ECLIPSE android 布局页面文件出错故障排除Exception raised during rendering: java.lang.System.arraycopy([CI[CII)V
非空 android 视图上的 java.lang.NullPointerException
Andriod之提示java.lang.SecurityException: getDataNetworkTypeForSubscriber导致程序奔溃
Andriod之提示java.lang.SecurityException: getDataNetworkTypeForSubscriber导致程序奔溃