Setting BitmapDrawable tileMode makes the app restart

此生再无相见时 提交于 2019-12-11 13:04:19

问题


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:

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()).

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).

Since

  • 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.


回答1:


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", or

  • 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.

Thanks for the help pskink anyway!



来源:https://stackoverflow.com/questions/39239789/setting-bitmapdrawable-tilemode-makes-the-app-restart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!