刷新SlidingTray中的视图时出现崩溃(来自顶部的自定义SlidingDrawer)。
我不确定导致它的原因..但我的第一个猜测是,这是由于嵌套布局的数量......
嵌套布局的最大数量是多少?
具体是设备,我怎么能确定是否是原因?
如果不是,那么这些东西都会导致它......是什么?
stacktrace:
E/AndroidRuntime( 2199): FATAL EXCEPTION: main
E/AndroidRuntime( 2199): java.lang.StackOverflowError
E/AndroidRuntime( 2199): at android.graphics.Paint.measureText(Paint.java:1057)
E/AndroidRuntime( 2199): at android.text.Styled.drawDirectionalRun(Styled.java:267)
E/AndroidRuntime( 2199): at android.text.Styled.measureText(Styled.java:430)
E/AndroidRuntime( 2199): at android.text.Layout.measureText(Layout.java:1655)
E/AndroidRuntime( 2199): at android.text.Layout.getLineMax(Layout.java:689)
E/AndroidRuntime( 2199): at android.text.Layout.draw(Layout.java:340)
E/AndroidRuntime( 2199): at android.text.BoringLayout.draw(BoringLayout.java:365)
E/AndroidRuntime( 2199): at android.widget.TextView.onDraw(TextView.java:4168)
E/AndroidRuntime( 2199): at android.view.View.draw(View.java:6880)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.View.draw(View.java:6883)
E/AndroidRuntime( 2199): at android.widget.FrameLayout.draw(FrameLayout.java:357)
E/AndroidRuntime( 2199): at android.widget.ScrollView.draw(ScrollView.java:1409)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.View.draw(View.java:6883)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.View.buildDrawingCache(View.java:6640)
E/AndroidRuntime( 2199): at android.view.View.getDrawingCache(View.java:6428)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1571)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1392)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.View.draw(View.java:6883)
E/AndroidRuntime( 2199): at android.widget.FrameLayout.draw(FrameLayout.java:357)
E/AndroidRuntime( 2199): at android.widget.ScrollView.draw(ScrollView.java:1409)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.View.draw(View.java:6986)
E/AndroidRuntime( 2199): at android.widget.FrameLayout.draw(FrameLayout.java:357)
E/AndroidRuntime( 2199): at android.widget.HorizontalScrollView.draw(HorizontalScrollView.java:1409)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.View.draw(View.java:6883)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.View.draw(View.java:6883)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
E/AndroidRuntime( 2199): at com.vodafone.onm.components.SlidingTray.dispatchDraw(SlidingTray.java:426)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.View.draw(View.java:6883)
E/AndroidRuntime( 2199): at android.widget.FrameLayout.draw(FrameLayout.java:357)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.View.draw(View.java:6883)
E/AndroidRuntime( 2199): at android.widget.FrameLayout.draw(FrameLayout.java:357)
E/AndroidRuntime( 2199): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java)
更新: 层次结构查看器快照
有些人认为我认为是相关的: http://www.mail-archive.com/android-developers@googlegroups.com/msg48036.html
答案 0 :(得分:22)
嵌套布局的最大数量是多少?
没有具体的价值。当用完堆栈空间时,你的堆栈空间不足,这将取决于你正在做什么。主应用程序线程有一个8KB的堆栈,我听说过。
话虽如此,如果层次结构视图显示的深度为10或更高(根到最深的叶子),我开始变得紧张,到15岁时你可能会开始遇到异常。您的图像几乎难以辨认,其图像的深度远远高于此值。
您似乎有许多浪费的图层。如果在层次结构视图中有一个层,在关键路径上有一个父项和一个子项,那么它是要删除的主要候选项,因为它可能不会添加任何值。你至少有5个这样的候选人。即使清理所有这些也可能还不够,但这是一个起点。