Allow experimental hardware acceleration with a disclaimer
@@ -191,6 +191,22 @@ public class LottieAnimationView extends AppCompatImageView {
lottieDrawable.recycleBitmaps();
}
+ /**
+ * Enable hardware acceleration for this view.
+ * READ THIS BEFORE ENABLING HARDWARE ACCELERATION:
+ * 1) Test your animation on the minimum API level you support. Some drawing features such as
+ * dashes and stroke caps have min api levels
+ * (https://developer.android.com/guide/topics/graphics/hardware-accel.html#unsupported)
+ * 2) Enabling hardware acceleration is not always more performant. Check it with your specific
+ * animation only if you are having performance issues with software rendering.
+ * 3) Software rendering is safer and will be consistent across devices. Manufacturers can
+ * potentially break hardware rendering with bugs in their SKIA engine. Lottie cannot do
+ * anything about that.
+ */
+ @SuppressWarnings("WeakerAccess") public void useExperimentalHardwareAcceleration() {
+ setLayerType(LAYER_TYPE_HARDWARE, null);
+ }
+
/**
* Sets the animation from a file in the assets directory.
* This will load and deserialize the file asynchronously.
