在Android M设备上使用Ripple Effect Library的IllegalStateException

Ore*_*reo 6 android ripple android-6.0-marshmallow android-6.0.1-marshmallow

使用 library来实现Ripple Effect除了Android M设备上工作正常.

在Android M设备上获得的信息IllegalStateException表明恢复中的下溢 - 恢复比恢复更多

FATAL EXCEPTION: main
Process: com.example.ripplethings, PID: 20119
java.lang.IllegalStateException: Underflow in restore - more restores than saves
at android.graphics.Canvas.native_restore(Native Method)
at android.graphics.Canvas.restore(Canvas.java:540)
at com.andexert.library.RippleView.draw(RippleView.java:166)
Run Code Online (Sandbox Code Playgroud)

Ren*_*K N 5

它似乎是Android 6.0中库本身的一个错误,避免错误的可能方法是

1)使用com.balysv:material-ripple:1.0.2库看起来更稳定

2)或者你可以使用21+的单独布局让Android M处理涟漪本身.只需使用适当的纹波支架即可进行布局和视图

3)或者您可以根据建议修改库源代码本身

4)@ git提供了这个库的固定版本,你可以在你的gradle中使用它

compile 'com.github.Hitta:RippleEffect:82cf00e551'
repositories {
            ...
            maven { url "https://jitpack.io" }
        }
Run Code Online (Sandbox Code Playgroud)