2013-10-05 225 views
0

我正面臨棧溢出錯誤,我搜索了很多資源,但我無法找到解決方案。我在3個選項卡中使用此佈局,前2個選項卡是活動它沒有顯示任何錯誤,但對於第3顯示錯誤。堆棧溢出錯誤android

第三個選項卡我作爲一個選項卡活動

這裏是我的logcat:

10-03 10:42:14.090: E/AndroidRuntime(302): FATAL EXCEPTION: main 
10-03 10:42:14.090: E/AndroidRuntime(302): java.lang.StackOverflowError 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.text.Styled.drawUniformRun(Styled.java:61) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.text.Styled.drawDirectionalRun(Styled.java:298) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.text.Styled.drawText(Styled.java:357) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.text.Layout.drawText(Layout.java:1387) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.text.Layout.draw(Layout.java:370) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.text.BoringLayout.draw(BoringLayout.java:365) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.widget.TextView.onDraw(TextView.java:4050) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.View.draw(View.java:6740) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.drawChild(ViewGroup.java:1640) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.View.draw(View.java:6743) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.drawChild(ViewGroup.java:1640) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.widget.AbsListView.dispatchDraw(AbsListView.java:1365) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.widget.ListView.dispatchDraw(ListView.java:3046) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.View.draw(View.java:6846) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.widget.AbsListView.draw(AbsListView.java:2257) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.drawChild(ViewGroup.java:1640) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.drawChild(ViewGroup.java:1638) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.View.draw(View.java:6743) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.drawChild(ViewGroup.java:1640) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.View.draw(View.java:6743) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.widget.FrameLayout.draw(FrameLayout.java:352) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.drawChild(ViewGroup.java:1640) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.drawChild(ViewGroup.java:1638) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.View.draw(View.java:6743) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.widget.FrameLayout.draw(FrameLayout.java:352) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.drawChild(ViewGroup.java:1640) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.drawChild(ViewGroup.java:1638) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.View.draw(View.java:6743) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.widget.FrameLayout.draw(FrameLayout.java:352) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.drawChild(ViewGroup.java:1640) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.drawChild(ViewGroup.java:1638) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.View.draw(View.java:6743) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.widget.FrameLayout.draw(FrameLayout.java:352) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.drawChild(ViewGroup.java:1640) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.drawChild(ViewGroup.java:1638) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.View.draw(View.java:6743) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.widget.FrameLayout.draw(FrameLayout.java:352) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.drawChild(ViewGroup.java:1640) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.drawChild(ViewGroup.java:1638) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.drawChild(ViewGroup.java:1638) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.drawChild(ViewGroup.java:1638) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.drawChild(ViewGroup.java:1638) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.View.draw(View.java:6743) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.widget.FrameLayout.draw(FrameLayout.java:352) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.drawChild(ViewGroup.java:1640) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.View.draw(View.java:6743) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.widget.FrameLayout.draw(FrameLayout.java:352) 
10-03 10:42:14.090: E/AndroidRuntime(302): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1842) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewRoot.draw(ViewRoot.java:1407) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewRoot.performTraversals(ViewRoot.java:1163) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.view.ViewRoot.handleMessage(ViewRoot.java:1727) 
10-03 10:42:14.090: E/AndroidRuntime(302): at android.os.Handler.dispatchMessage(Handl 

這裏是我的佈局

  1. <RatingBar 
         android:id="@+id/imageView2" 
         style="@style/foodRatingBar" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_marginTop="2dp" 
         android:visibility="invisible" /> 
    
        <Button 
         android:id="@+id/button2" 
         style="?android:attr/buttonStyleSmall" 
         android:layout_width="45dp" 
         android:layout_height="35dp" 
         android:background="@drawable/setting_btn" /> 
    
    </LinearLayout> 
    
    <TextView 
        android:id="@+id/textView1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentLeft="true" 
        android:layout_below="@+id/frame" 
        android:layout_marginLeft="10dp" 
        android:layout_marginTop="10dp" 
        android:text="Mary Smith" 
        android:textColor="#585858" 
        android:textSize="16dp" 
        android:textStyle="bold" /> 
    
    <TextView 
        android:id="@+id/textView2" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignBaseline="@+id/textView1" 
        android:layout_alignBottom="@+id/textView1" 
        android:layout_marginLeft="5dp" 
        android:layout_toRightOf="@+id/textView1" 
        android:text="asks:" 
        android:textColor="#a6a6a6" 
        android:textSize="15dp" /> 
    
    <FrameLayout 
        android:id="@+id/frameLayout1" 
        android:layout_width="fill_parent" 
        android:layout_height="20dp" 
        android:layout_below="@+id/textView3" 
        android:layout_marginLeft="15dp" 
        android:layout_marginTop="10dp" 
        android:layout_toLeftOf="@+id/textView5" 
        android:layout_toRightOf="@+id/button5" > 
    </FrameLayout> 
    
    <Button 
        android:id="@+id/button8" 
        style="?android:attr/buttonStyleSmall" 
        android:layout_width="90dp" 
        android:layout_height="25dp" 
        android:layout_alignRight="@+id/editText1" 
        android:layout_below="@+id/editText1" 
        android:layout_marginTop="5dp" 
        android:background="@drawable/vote_btnimg" /> 
    
    <ImageView 
        android:id="@+id/button5" 
        android:layout_width="60dp" 
        android:layout_height="55dp" 
        android:layout_alignTop="@+id/frameLayout1" 
        android:scaleType="fitCenter" 
        android:layout_marginLeft="5dp" /> 
    
    <EditText 
        android:id="@+id/editText1" 
        android:layout_width="wrap_content" 
        android:layout_height="60dp" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentRight="true" 
        android:layout_below="@+id/button5" 
        android:layout_marginLeft="10dp" 
        android:layout_marginRight="10dp" 
        android:layout_marginTop="25dp" 
        android:background="@drawable/ask_question_box" 
        android:gravity="top" 
        android:hint="Add your comment here" 
        android:imeOptions="actionDone" 
        android:inputType="textMultiLine" 
        android:maxLines="10" 
        android:paddingLeft="10dp" 
        android:paddingTop="8dp" 
        android:singleLine="false" 
        android:textColor="#d5d5d5" 
        android:textSize="12dp" /> 
    
    <Button 
        android:id="@+id/button3" 
        style="?android:attr/buttonStyleSmall" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignRight="@+id/editText1" 
        android:layout_alignTop="@+id/textView2" 
        android:visibility="visible" 
        android:background="@drawable/report_btn" /> 
    
    <ToggleButton 
        android:id="@+id/imageView3" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignBaseline="@+id/button3" 
        android:layout_alignBottom="@+id/button3" 
        android:layout_toLeftOf="@+id/button3" 
        android:background="@drawable/follower_toggle" 
        android:button="@null" 
        android:soundEffectsEnabled="true" 
        android:textOff="" 
        android:visibility="invisible" 
        android:textOn="" /> 
    
    <Button 
        android:id="@+id/button4" 
        android:layout_width="wrap_content" 
        android:layout_height="30dp" 
        android:layout_alignBottom="@+id/button5" 
        android:layout_alignLeft="@+id/frameLayout1" 
        android:background="@drawable/button_selecter_yes" /> 
    

    <ListView 
         android:id="@+id/listview" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_alignParentLeft="true" 
         android:layout_below="@+id/imageView2" 
         android:layout_marginTop="18dp" 
         android:divider="@null" 
         android:dividerHeight="0dp" 
         android:fadingEdgeLength="0dp" > 
        </ListView> 
    </RelativeLayout> --> 
    
    <!-- <TextView 
        android:id="@+id/textView4" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignLeft="@+id/editText1" 
        android:layout_alignTop="@+id/button8" 
        android:text="Rate this Question :" 
        android:textColor="#000000" 
        android:visibility="invisible" 
        android:textSize="12dp" /> --> 
    
    <TextView 
        android:id="@+id/textView3" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignLeft="@+id/textView1" 
        android:layout_alignRight="@+id/button3" 
        android:layout_below="@+id/button3" 
        android:text="which shirt is sutable for me" 
        android:textColor="#999999" 
        android:textSize="15dp" /> 
    
    <ProgressBar 
        android:id="@+id/imageView7" 
        style="@style/CustomProgressBar" 
        android:layout_width="150dp" 
        android:layout_height="wrap_content" 
        android:layout_alignLeft="@+id/button4" 
        android:layout_alignRight="@+id/button7" 
        android:layout_alignTop="@+id/button5" /> 
    
    - >
    <Button 
        android:id="@+id/button6" 
        android:layout_width="wrap_content" 
        android:layout_height="30dp" 
        android:layout_alignBaseline="@+id/button4" 
        android:layout_alignBottom="@+id/button4" 
        android:layout_marginLeft="10dp" 
        android:layout_toRightOf="@+id/button4" 
        android:background="@drawable/button_selecter_no" /> 
    
    <Button 
        android:id="@+id/button7" 
        style="?android:attr/buttonStyleSmall" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_above="@+id/editText1" 
        android:layout_alignRight="@+id/editText1" 
        android:layout_alignTop="@+id/button6" 
        android:background="@drawable/skip" /> 
    
    <TextView 
        android:id="@+id/textView6" 
        android:layout_width="40dp" 
        android:layout_height="17dp" 
        android:layout_alignBaseline="@+id/textView5" 
        android:layout_alignBottom="@+id/textView5" 
        android:layout_alignParentRight="true" 
        android:text="100%" 
        android:textColor="#000000" 
        android:textSize="10dp" 
        android:textStyle="bold" /> 
    
    <TextView 
        android:id="@+id/textView7" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignLeft="@+id/editText1" 
        android:layout_below="@+id/button5" 
        android:clickable="true" 
        android:text="Enlarge" 
        android:textAppearance="?android:attr/textAppearanceSmall" 
        android:textColor="#000000" 
        android:textSize="13dp" /> 
    
    <ListView 
        android:id="@+id/listview" 
        android:layout_below="@+id/button8" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentBottom="true" 
        android:layout_alignParentLeft="true" 
        android:divider="@null" 
        android:dividerHeight="0dp" 
        android:fadingEdgeLength="0dp" > 
    </ListView> 
    
    <TextView 
        android:id="@+id/textView5" 
        android:layout_width="40dp" 
        android:layout_height="17dp" 
        android:layout_above="@+id/button4" 
        android:layout_toRightOf="@+id/textView1" 
        android:text="100%" 
        android:textColor="#000000" 
        android:textSize="10dp" 
        android:textStyle="bold" /> 
    

+0

如果logcat不清楚,請參閱此日誌貓並做一些需要完整http://stackoverflow.com/questions/19151898/stack- 「流量錯誤 - 安卓文本樣式」 – user228989

+0

「需要充足嗎?」謹慎解釋? –

回答

0

檢查您繪製的圖像尺寸..
圖像尺寸可能有堆棧溢出的原因。
嘗試使用較小尺寸的圖像.....

+0

所有圖片均以KB爲單位,小於20 kb – user228989

+0

查看此鏈接.. 它可能會幫助你。 [鏈接](http://stackoverflow.com/questions/9737286/android-stackoverflow-error) – AmmY

1

在相對佈局內的某處可能存在循環視圖依賴關係。我可以看到frameLayout1視圖取決於button5,而且button5取決於framelayout1

這創建了一個循環,可能會導致您的問題,因爲android試圖解決和放置在屏幕上的意見,並陷入這個無限循環的依賴。請仔細檢查一下,並優先使用視圖創建者的相對佈局insead手動輸入它