相关疑难解决方法(0)

如何在Android中的TextView或EditText中添加动画表情符号

作为问题,我使用ImageSpan将图像添加到TextView中.但是它不能
动画.你有任何建议吗?我尝试扩展AnimationDrawable以将drawable添加到ImageSpan中.但它不起作用

public class EmoticonDrawalbe extends AnimationDrawable {
    private Bitmap bitmap;
    private GifDecode decode;
    private int gifCount;

    public EmoticonDrawalbe(Context context, String source) {
        decode = new GifDecode();
        decode.read(context, source);
        gifCount = decode.getFrameCount();
        if (gifCount <= 0) {
            return;
        }
        for (int i = 0; i < gifCount; i++) {
            bitmap = decode.getFrame(i);
            addFrame(new BitmapDrawable(bitmap), decode.getDelay(i));
        }
        setOneShot(false);
    }

    @Override
    public void draw(Canvas canvas) {
        super.draw(canvas);
        start();
    }
}
Run Code Online (Sandbox Code Playgroud)

android gif

8
推荐指数
2
解决办法
9307
查看次数

标签 统计

android ×1

gif ×1