android中的堆栈溢出错误

时间:2013-04-27 06:15:27

标签: android xml stack-overflow

以下是我的logcat error,我查找并搜索但我无法得到究竟错误的内容。 请有人帮助我,我的sender.xml文件中有很多视图,如图片,视频,文字。

Logcat错误

 java.lang.StackOverflowError
    at android.text.Styled.drawDirectionalRun(Styled.java:267)
    at android.text.Styled.measureText(Styled.java:430)
    at android.text.Layout.measureText(Layout.java:1655)
    at android.text.Layout.getLineMax(Layout.java:689)
    at android.text.Layout.draw(Layout.java:340)
    at android.text.BoringLayout.draw(BoringLayout.java:365)
    at android.widget.TextView.onDraw(TextView.java:4422)
    at android.view.View.draw(View.java:6880)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1649)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1376)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1647)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1376)
    at android.view.View.draw(View.java:6883)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1649)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1376)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1647)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1376)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1647)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1376)
    at android.view.View.draw(View.java:6883)
    at android.view.View.buildDrawingCache(View.java:6642)
    at android.view.View.getDrawingCache(View.java:6428)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1574)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1376)
    at android.widget.AbsListView.dispatchDraw(AbsListView.java:1480)
    at android.widget.ListView.dispatchDraw(ListView.java:3138)
    at android.view.View.draw(View.java:6883)
    at android.widget.AbsListView.draw(AbsListView.java:2584)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1649)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1376)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1647)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1376)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1647)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1376)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1647)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1376)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1647)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1376)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1647)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1376)
    at android.view.View.draw(View.java:6883)
    at android.widget.FrameLayout.draw(FrameLayout.java:357)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1649)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1376)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1647)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1376)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1647)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1376)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1647)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1376)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1647)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1376)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1647)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1376)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1647)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1376)
    at android.view.View.draw(View.java:6883)
    at android.widget.FrameLayout.draw(FrameLayout.java:357)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1649)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1376)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1647)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1376)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1647)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1376)
    at android.view.View.draw(View.java:6883)
    at android.widget.FrameLayout.draw(FrameLayout.java:357)
    at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1866)
    at android.view.ViewRoot.draw(ViewRoot.java:1528)
    at android.view.ViewRoot.performTraversals(ViewRoot.java:1258)
    at android.view.ViewRoot.handleMessage(ViewRoot.java:1865)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:130)
    at android.app.ActivityThread.main(ActivityThread.java:3822)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
    at dalvik.system.NativeStart.main(Native Method)

这是我的sender.xml文件

 <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#ffffff"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/dtbar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="20dp"
            android:background="@drawable/date_back"
            android:gravity="center"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#ffffff"
            android:textSize="16dip"
            android:textStyle="bold" />

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:weightSum="1" >

            <FrameLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="30dp"
                android:layout_weight="0.3" >

                <ImageView
                    android:layout_width="fill_parent"
                    android:layout_height="66dp"
                    android:background="@drawable/friends_popup_photoframe"
                    android:scaleType="centerInside" />

                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center|center_horizontal"
                    android:gravity="center|center_horizontal"
                    android:weightSum="1" >

                    <RelativeLayout
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_weight="0.7"
                        android:gravity="center" >

                        <ImageView
                            android:id="@+id/user_img"
                            android:layout_width="wrap_content"
                            android:layout_height="50dp"
                            android:layout_centerInParent="true"
                            android:layout_gravity="center|fill_horizontal"
                            android:adjustViewBounds="true"
                            android:scaleType="centerInside" />
                    </RelativeLayout>
                </LinearLayout>
            </FrameLayout>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginRight="10dp"
                android:layout_marginTop="25dp"
                android:layout_weight="0.7"
                android:orientation="vertical" >

                <LinearLayout
                    android:id="@+id/evenchatlay"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:orientation="vertical" >

                    <LinearLayout
                        android:id="@+id/evenlay"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal" >

                        <TextView
                            android:id="@+id/usernm"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="left"
                            android:layout_marginBottom="2dp"
                            android:gravity="left"
                            android:singleLine="false"
                            android:textColor="#DF0101"
                            android:textSize="16dip"
                            android:textStyle="bold" />

                        <TextView
                            android:id="@+id/time"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="left|bottom"
                            android:layout_marginLeft="5dp"
                            android:layout_marginTop="3dp"
                            android:ems="15"
                            android:gravity="left|bottom"
                            android:maxEms="15"
                            android:singleLine="true"
                            android:textColor="#000000"
                            android:textSize="12dip"
                            android:textStyle="bold" />
                    </LinearLayout>

                    <TextView
                        android:id="@+id/text"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="right|center"
                        android:ems="15"
                        android:gravity="left|center_vertical"
                        android:maxEms="15"
                        android:singleLine="false"
                        android:textColor="#000000"
                        android:textSize="16dip" />

                    <ImageView
                        android:id="@+id/chat_emojis"
                        android:layout_width="50dp"
                        android:layout_height="50dp"
                        android:layout_gravity="left"
                        android:layout_marginLeft="10dp"
                        android:layout_marginTop="2dip"
                        android:gravity="left"
                        android:scaleType="centerInside"
                        android:visibility="gone" />

                    <LinearLayout
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal" >

                        <FrameLayout
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >

                            <ImageView
                                android:id="@+id/chat_img"
                                android:layout_width="50dp"
                                android:layout_height="50dp"
                                android:layout_marginLeft="10dp"
                                android:layout_marginTop="2dip"
                                android:scaleType="centerInside"
                                android:visibility="gone" />

                            <ImageView
                                android:id="@+id/playbtn"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:layout_marginLeft="5dp"
                                android:background="@drawable/play"
                                android:scaleType="centerInside"
                                android:visibility="gone" />

                            <ProgressBar
                                android:id="@+id/progressBar2"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:visibility="gone" />
                        </FrameLayout>

                        <Button
                            android:id="@+id/save"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="2dp"
                            android:layout_marginTop="5dp"
                            android:background="@drawable/downloadbtn_focus"
                            android:text="Save"
                            android:textColor="#ffffff"
                            android:visibility="gone" />

                        <Button
                            android:id="@+id/cancel"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center"
                            android:layout_marginLeft="2dp"
                            android:background="@drawable/downloadbtn_focus"
                            android:text="cancel"
                            android:textColor="#ffffff"
                            android:visibility="gone" />
                    </LinearLayout>

                    <RelativeLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" >

                        <ProgressBar
                            android:id="@+id/progressBar1"
                            style="?android:attr/progressBarStyleHorizontal"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="bottom"
                            android:layout_marginLeft="10dp"
                            android:layout_toLeftOf="@+id/linearimg"
                            android:layout_toRightOf="@+id/linearimg"
                            android:visibility="gone" />
                    </RelativeLayout>
                </LinearLayout>
            </LinearLayout>
        </LinearLayout>

    </LinearLayout>

1 个答案:

答案 0 :(得分:1)

你有(太多)嵌套布局。您可以访问d.android.com上的官方Android博客,获取有关如何优化布局的提示和技巧。

了解更多信息have a look on this question

一切顺利。快乐的编码。