• Runtimes
  • Android super simple buitlin platform Drawable!

I made android platform Drawable which can draw animated Spine.
This is just proof of concept, that Spine can be used inside regular android ImageView or treat it as AnimatedDrawable. So we can swap the content while preserving the Android View. Which current spine-android-runtime could not do.

AndroidView(
    factory = {
        val view = ImageView(it)
        val spine = AndroidSkeletonDrawable.fromAsset("spineboy.atlas", "spineboy-pro.json", it)
        val drawable = SpineDrawable(spine)
        view.setImageDrawable(drawable)
        drawable.boundProvider = SkinAndAnimationBounds(listOf("default"),"idle")
       spine.animationState.setAnimation(0, "idle", true)
       drawable.start()
        view
  },
   modifier = Modifier.background(Color.Cyan),
   update = {  }
)

It only need two files and official Spine-Android runtime library. You can find the source code from my gist

  • Drawable ColorFilter setter is not tested
Related Discussions
...

Could you elaborate what this enables compared to what we currently have implemented?

  • pbk ответили на это сообщение.

    Mario

    First of all, I was mistaken with the iOS implementation. (iOS cannot change the Skeleton of SpineView.). Current Android Spine-runtime does able to replace Skeleton of SpineView.

    My code wraps Skeleton as android Drawable

    1. It is easy to integrate with existing View Layouts.
      setForeground, setBackground, setImageDrawable these are common method of using Drawable. No need to add or replace the existing layout, just replace the existing contents of View!

    2. Combine with various existing Drawable Wrapper
      android platform has many Drawable Wrapper which can modify the behavior of Drawing without modify the actual Drawable.
      Drawable
      ex) RotateDrawble, DrawableContainer, ClipDrawable, InsetDrawable ...

    side-note)
    My solution is naive, it can be improved by adapting setState, getTransparent Region, opticalInset, etc.