Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Feb 6, 2023. It is now read-only.

Dynamic Drawer

PonyCui edited this page Dec 19, 2018 · 1 revision

Additionally, you want to draw things on element in animation.

Download Sample File

You can download a sample file from SVGA-Samples to try.

Step

Load animation as usual.

// Setup a SVGAImageView by yourself.
try {
 parser.parse(new URL("https://github.com/yyued/SVGA-Samples/blob/master/kingset.svga?raw=true"), 
 new SVGAParser.ParseCompletion() {
 @Override
 public void onComplete(@NotNull SVGAVideoEntity videoItem) {
 }
 @Override
 public void onError() {
 }
 }
 );
} catch (Exception e) {
 System.out.print(true);
}

Setup drawer.

try {
 parser.parse(new URL("https://github.com/yyued/SVGA-Samples/blob/master/kingset.svga?raw=true"), 
 new SVGAParser.ParseCompletion() {
 @Override
 public void onComplete(@NotNull SVGAVideoEntity videoItem) {
 SVGADynamicEntity dynamicEntity = new SVGADynamicEntity();
 dynamicEntity.setDynamicDrawer(new Function2<Canvas, Integer, Boolean>() {
 @Override
 public Boolean invoke(Canvas canvas, Integer frameIndex) {
 Paint aPaint = new Paint();
 aPaint.setColor(Color.WHITE);
 canvas.drawCircle(50, 54, frameIndex % 5, aPaint);
 return false;
 }
 }, "banner");
 SVGADrawable drawable = new SVGADrawable(videoItem, dynamicEntity);
 testView.setImageDrawable(drawable);
 testView.startAnimation();
 }
 @Override
 public void onError() {
 }
 }
 );
} catch (Exception e) {
 System.out.print(true);
}

As result, you see a circle drawn on the banner.

ImageKey

The imageKey is the name of png file, ask your designer tell you the file name.

For example, the layer png image file name is xxx.png, imageKey is xxx. File name should always use English name, do not use Chinese or Japanese etc.

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /