我想用一個PNG圖像中一個TextView的背景添加一些連鎖反應,發現this Post設置背景繪製到TextView的casues java.lang.StackOverflowError的
我action_darwer.xml繪製作爲
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="?attr/selectableItemBackgroundBorderless" android:state_pressed="true" /> <!-- pressed -->
<item android:drawable="@drawable/drawer" /> <!-- default -->
</selector>
並將其設置爲TextView的作爲
<TextView android:id="@+id/action_drawer"
android:layout_marginLeft="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/action_drawer"/>
它不是在所有的工作,並給予錯誤
java.lang.StackOverflowError: stack size 8MB
at android.content.res.ColorStateList.valueOf(ColorStateList.java:102)
at android.graphics.drawable.RippleDrawable$RippleState.<init>(RippleDrawable.java:919)
at android.graphics.drawable.RippleDrawable.createConstantState(RippleDrawable.java:914)
at android.graphics.drawable.RippleDrawable.createConstantState(RippleDrawable.java:94)
at android.graphics.drawable.LayerDrawable.<init>(LayerDrawable.java:126)
at android.graphics.drawable.LayerDrawable.<init>(LayerDrawable.java:122)
at android.graphics.drawable.RippleDrawable.<init>(RippleDrawable.java:979)
at android.graphics.drawable.RippleDrawable.<init>(RippleDrawable.java:94)
at android.graphics.drawable.RippleDrawable$RippleState.newDrawable(RippleDrawable.java:945)
at android.content.res.Resources.getCachedDrawableLocked(Resources.java:2777)
at android.content.res.Resources.getCachedDrawable(Resources.java:2745)
at android.content.res.Resources.loadDrawable(Resources.java:2586)
at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
at android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:182)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:127)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1133)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1037)
at android.content.res.Resources.loadDrawableForCookie(Resources.java:2718)
at android.content.res.Resources.loadDrawable(Resources.java:2614)
at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
at android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:182)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:127)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1133)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1037)
at android.content.res.Resources.loadDrawableForCookie(Resources.java:2718)
at android.content.res.Resources.loadDrawable(Resources.java:2614)
at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
at android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:182)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:127)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1133)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1037)
at android.content.res.Resources.loadDrawableForCookie(Resources.java:2718)
at android.content.res.Resources.loadDrawable(Resources.java:2614)
at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
at android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:182)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:127)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1133)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1037)
at android.content.res.Resources.loadDrawableForCookie(Resources.java:2718)
at android.content.res.Resources.loadDrawable(Resources.java:2614)
at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
at android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:182)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:127)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1133)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1037)
at android.content.res.Resources.loadDrawableForCookie(Resources.java:2718)
at android.content.res.Resources.loadDrawable(Resources.java:2614)
at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
at android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:182)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:127)
at android.graphi
02-16 13:12:53.567 22641-22641/org.team.asl.carticon E/JavaBinder: !!! FAILED BINDER TRANSACTION !!!
02-16 13:12:53.568 22641-22641/org.team.asl.carticon E/AndroidRuntime: Error reporting crash
android.os.TransactionTooLargeException
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:504)
at android.app.ActivityManagerProxy.handleApplicationCrash(ActivityManagerNative.java:4294)
at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:89)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
如何解決這個問題?任何建議將不勝感激。謝謝。
顯示'抽拉/ drawer'代碼,或它是一個圖像? –
@VladMatvienko是的,這是一個圖像! –
你確定嗎?你能發佈資源文件夾結構的截圖嗎? –