Setting BitmapDrawable tileMode makes the app rest

2019-07-25 16:05发布

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条回答
Anthone
2楼-- · 2019-07-25 16:42

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!

查看更多
登录 后发表回答