设置BitmapDrawable tileMode可使应用重新启动 [英] Setting BitmapDrawable tileMode makes the app restart
问题描述
虽然我的应用在大多数设备上都运行良好,但在某些设备上(到目前为止,LG G3,三星Galaxy S6)我遇到了一个奇怪的错误,但我无法真正展现:
While on most of the devices my app is working fine, on some devices (LG G3, Samsung Galaxy S6 so far) I have experienced a strange error, I can not really unfold:
将tileMode
(通过XML或以编程方式)设置为BitmapDrawable
(布局的背景)上的任何内容(clamp
/repeat
/mirror
),会使背景完全变成黑色,并在约20秒后重新启动应用程序-没有任何错误迹象(LogCat中没有消息,我活动的这些回调均未调用:onPause()
,onStop()
,onDestroy()
).
Setting tileMode
(either via XML or programmatically) to anything (clamp
/repeat
/mirror
) on a BitmapDrawable
, that is the backround of a layout, makes that background completely black-, and the app restart after ~20 seconds - without any sign of anything going wrong (no messages in LogCat, none of these callbacks of my activity is called: onPause()
, onStop()
, onDestroy()
).
由于根据使用的Bitmap
这些冻结/崩溃之间存在一些不一致,因此我开始尝试使用.png
图像,并弄清楚了我可以摆脱(大多数)崩溃,如果我减小这些图像的尺寸(<200x200).
As there were some inconsistency among these freezes/crashes depending on the Bitmap
being used, I started playing around with the .png
images, and figured out, that I can get rid of (most of) these crashes, if I reduce the size of these images (<200x200).
自
-
仍然有些崩溃,并且
there are still some crashes and
我不确定所有设备的大小阈值
I can not be sure about that size threshold for all the devices
我仍在寻找一种通用的解决方案,也许有些人可以帮助我.
I am still looking for a general solution, maybe some of you can help me with.
推荐答案
尽管此线程与我遇到的问题并不完全相同,它意外地帮助了我.将相关布局的layerType
设置为software
,如
Although this thread was not exactly about the same problem I had, it helped me accidentally. Setting the layerType
of the layout in question to software
like
-
android:layerType="software"
或
view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
设置黑色背景,应用重新启动消失.
made the black backgrounds and the app restarts disappear.
事实证明,缩小背景图像并不能解决问题,只会使其出现的频率降低.
It turned out also, that making the background images smaller didn't solve the problem, it only made it appear less often.
仍然感谢您的帮助!
这篇关于设置BitmapDrawable tileMode可使应用重新启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!