Look at your app with the Hierarchy Viewer, and look at ways to
reimplement parts of your UI so that the hierarchy is shallower.

So, for example, you might replace two nested LinearLayouts with one
RelativeLayout, to get the same result with a shallower tree.

You could also take a look at Romain Guy's blog article on the
subject:
http://android-developers.blogspot.com/2009/03/android-layout-tricks-3-optimize-by.html

Richard


On May 11, 3:16 pm, manoj <[email protected]> wrote:
> How can I lessen the number of views in my layout?
>
> can you please suggest me in detail?
>
> Thanks,
> Manoj.
>
> On May 11, 6:19 pm, Streets Of Boston <[email protected]> wrote:
>
> > I'm not absolutely sure, but i remember reading that sdk1.5 is much
> > much more conservative on the allowable depth and width of your
> > screen's layout.
>
> > If you go very deep (from parent-views to child-views) or very wide
> > (many 'sibling' views), sdk1.1 had a bit of a hard time, but could
> > handle it. However, sdk1.5 is much more finnicky and may crash if your
> > view-hierarchy is too deep or wide.
>
> > Based on your stack-trace, i count at least 13 'drawChild' calls. This
> > could be the problem. Try to lessen the number of views in your
> > layout.
>
> > On May 11, 9:04 am, manoj <[email protected]> wrote:
>
> > > Hi friends,
>
> > > I have developed an application which has tabActivity using SDK 1.0
> > > r2.
>
> > > 1st Tab contains List view. -> the list contains some images
>
> > > 2nd and 3rd contains some webviews.
>
> > > The app works fine on G1 mobile.
>
> > > Today I downloaded SDK 1.5 and ran the same app on SDK 1.5.
>
> > > The app got crashed when I scroll down/up the list items very fast
> > > (fling)
>
> > > I/dalvikvm( 1006): Stack overflow, expanding (0x41048200 to
> > > 0x41048000)
> > > I/dalvikvm( 1006): Shrank stack (to 0x41048200, curFrame is
> > > 0x41049cd8)
> > > D/AndroidRuntime( 1006): Shutting down VM
> > > W/dalvikvm( 1006): threadid=3: thread exiting with uncaught exception
> > > (group=0x4000fe70)
> > > E/AndroidRuntime( 1006): Uncaught handler: thread main exiting due to
> > > uncaught exception
> > > E/AndroidRuntime( 1006): java.lang.StackOverflowError
> > > E/AndroidRuntime( 1006):        at android.text.Styled.measureText
> > > (Styled.java:371)
> > > E/AndroidRuntime( 1006):        at android.text.Layout.measureText
> > > (Layout.java:1600)
> > > E/AndroidRuntime( 1006):        at android.text.Layout.getLineMax
> > > (Layout.java:654)
> > > E/AndroidRuntime( 1006):        at 
> > > android.text.Layout.draw(Layout.java:310)
> > > E/AndroidRuntime( 1006):        at android.text.BoringLayout.draw
> > > (BoringLayout.java:356)
> > > E/AndroidRuntime( 1006):        at android.widget.TextView.onDraw
> > > (TextView.java:3921)
> > > E/AndroidRuntime( 1006):        at android.view.View.draw(View.java:5838)
> > > E/AndroidRuntime( 1006):        at android.view.ViewGroup.drawChild
> > > (ViewGroup.java:1486)
> > > E/AndroidRuntime( 1006):        at android.view.ViewGroup.dispatchDraw
> > > (ViewGroup.java:1228)
> > > E/AndroidRuntime( 1006):        at android.view.View.buildDrawingCache
> > > (View.java:5615)
> > > E/AndroidRuntime( 1006):        at android.view.View.getDrawingCache
> > > (View.java:5458)
> > > E/AndroidRuntime( 1006):        at android.view.ViewGroup.drawChild
> > > (ViewGroup.java:1422)
> > > E/AndroidRuntime( 1006):        at android.view.ViewGroup.dispatchDraw
> > > (ViewGroup.java:1228)
> > > E/AndroidRuntime( 1006):        at android.widget.AbsListView.dispatchDraw
> > > (AbsListView.java:1319)
> > > E/AndroidRuntime( 1006):        at android.widget.ListView.dispatchDraw
> > > (ListView.java:2820)
> > > E/AndroidRuntime( 1006):        at android.view.View.draw(View.java:5944)
> > > E/AndroidRuntime( 1006):        at android.widget.AbsListView.draw
> > > (AbsListView.java:2121)
> > > E/AndroidRuntime( 1006):        at android.view.ViewGroup.drawChild
> > > (ViewGroup.java:1486)
> > > E/AndroidRuntime( 1006):        at android.view.ViewGroup.dispatchDraw
> > > (ViewGroup.java:1228)
> > > E/AndroidRuntime( 1006):        at android.view.ViewGroup.drawChild
> > > (ViewGroup.java:1484)
> > > E/AndroidRuntime( 1006):        at android.view.ViewGroup.dispatchDraw
> > > (ViewGroup.java:1228)
> > > E/AndroidRuntime( 1006):        at android.view.View.draw(View.java:5944)
> > > E/AndroidRuntime( 1006):        at android.widget.FrameLayout.draw
> > > (FrameLayout.java:352)
> > > E/AndroidRuntime( 1006):        at android.view.ViewGroup.drawChild
> > > (ViewGroup.java:1486)
> > > E/AndroidRuntime( 1006):        at android.view.ViewGroup.dispatchDraw
> > > (ViewGroup.java:1228)
> > > E/AndroidRuntime( 1006):        at android.view.ViewGroup.drawChild
> > > (ViewGroup.java:1484)
> > > E/AndroidRuntime( 1006):        at android.view.ViewGroup.dispatchDraw
> > > (ViewGroup.java:1228)
> > > E/AndroidRuntime( 1006):        at android.view.View.draw(View.java:5841)
> > > E/AndroidRuntime( 1006):        at android.widget.FrameLayout.draw
> > > (FrameLayout.java:352)
> > > E/AndroidRuntime( 1006):        at android.view.ViewGroup.drawChild
> > > (ViewGroup.java:1486)
> > > E/AndroidRuntime( 1006):        at android.view.ViewGroup.dispatchDraw
> > > (ViewGroup.java:1228)
> > > E/AndroidRuntime( 1006):        at android.view.ViewGroup.drawChild
> > > (ViewGroup.java:1484)
> > > E/AndroidRuntime( 1006):        at android.view.ViewGroup.dispatchDraw
> > > (ViewGroup.java:1228)
> > > E/AndroidRuntime( 1006):        at android.view.ViewGroup.drawChild
> > > (ViewGroup.java:1484)
> > > E/AndroidRuntime( 1006):        at android.view.ViewGroup.dispatchDraw
> > > (ViewGroup.java:1228)
> > > E/AndroidRuntime( 1006):        at android.view.ViewGroup.drawChild
> > > (ViewGroup.java:1484)
> > > E/AndroidRuntime( 1006):        at android.view.ViewGroup.dispatchDraw
> > > (ViewGroup.java:1228)
> > > E/AndroidRuntime( 1006):        at android.view.ViewGroup.drawChild
> > > (ViewGroup.java:1484)
> > > E/AndroidRuntime( 1006):        at android.view.ViewGroup.dispatchDraw
> > > (ViewGroup.java:1228)
> > > E/AndroidRuntime( 1006):        at android.view.View.draw(View.java:5841)
> > > E/AndroidRuntime( 1006):        at android.widget.FrameLayout.draw
> > > (FrameLayout.java:352)
> > > E/AndroidRuntime( 1006):        at android.view.ViewGroup.drawChild
> > > (ViewGroup.java:1486)
> > > E/AndroidRuntime( 1006):        at android.view.ViewGroup.dispatchDraw
> > > (ViewGroup.java:1228)
> > > E/AndroidRuntime( 1006):        at android.view.ViewGroup.drawChild
> > > (ViewGroup.java:1484)
> > > E/AndroidRuntime( 1006):        at android.view.ViewGroup.dispatchDraw
> > > (ViewGroup.java:1228)
> > > E/AndroidRuntime( 1006):        at android.view.View.draw(View.java:5841)
> > > E/AndroidRuntime( 1006):        at android.widget.FrameLayout.draw
> > > (FrameLayout.java:352)
> > > E/AndroidRuntime( 1006):        at
> > > com.android.internal.policy.impl.PhoneWindow$DecorView.draw
> > > (PhoneWindow.java:1847)
> > > E/AndroidRuntime( 1006):        at 
> > > android.view.ViewRoot.draw(ViewRoot.java:
> > > 1217)
> > > E/AndroidRuntime( 1006):        at android.view.ViewRoot.performTraversals
> > > (ViewRoot.java:1030)
> > > E/AndroidRuntime( 1006):        at android.view.ViewRoot.handleMessage
> > > (ViewRoot.java:1482)
> > > E/AndroidRuntime( 1006):        at android.os.Handler.dispatchMessage
> > > (Handler.java:99)
> > > E/AndroidRuntime( 1006):        at android.os.Looper.loop(Looper.java:123)
> > > E/AndroidRuntime( 1006):        at android.app.ActivityThread.main
> > > (ActivityThread.java:3948)
> > > E/AndroidRuntime( 1006):        at java.lang.reflect.Method.invokeNative
> > > (Native Method)
> > > E/AndroidRuntime( 1006):        at java.lang.reflect.Method.invoke
> > > (Method.java:521)
> > > E/AndroidRuntime( 1006):        at com.android.internal.os.ZygoteInit
> > > $MethodAndArgsCaller.run(ZygoteInit.java:782)
> > > E/AndroidRuntime( 1006):        at com.android.internal.os.ZygoteInit.main
> > > (ZygoteInit.java:540)
> > > E/AndroidRuntime( 1006):        at dalvik.system.NativeStart.main(Native
> > > Method)
>
> > > I am not understanding the above error log.
>
> > > Then I experimented some thing like this: I removed the TabActivity,
> > > just shown only list activity. Then I scroll down/up the list items.
> > > Then there is no crash.
>
> > > Can any one please help me.
>
> > > Thanks,
> > > manoj.
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to