相关疑难解决方法(0)

Android动画,同时移动和旋转

我正在制作动画图像视图,并向右移动并同时旋转.我可以让物品移动使用

    animation = new TranslateAnimation(0, level, 0, 0);
animation.setDuration(1000);
animation.setRepeatCount(0);
animation.setFillAfter(true);
Run Code Online (Sandbox Code Playgroud)

Level是我当时定义的变量.我知道旋转的代码是

RotateAnimation rotate = new RotateAnimation(0,rotate,0,0);
    rotate.setDuration(1000);
    rotate.setRepeatCount(0);
    animation.setFillAfter(true);
    bPick.setAnimation(rotate);
Run Code Online (Sandbox Code Playgroud)

再次旋转是我在顶部定义的变量.

我的问题是,我如何将这两者结合起来?我尝试过使用一个帖子

    private Runnable myThread = new Runnable() {

    @Override
    public void run() {
        while (level < 100) {
            try {
                myHandle.sendMessage(myHandle.obtainMessage());
                Thread.sleep(15);
            } catch (Throwable t) {
            }
        }

    }

    Handler myHandle = new Handler() {

        @Override
        public void handleMessage(Message msg) {

            level++;
            animation = new TranslateAnimation(0, level, 0, 0);
            animation.setDuration(1000);
            animation.setRepeatCount(0);
            animation.setFillAfter(true);
            bPick.setAnimation(animation);

        }
    };
};
Run Code Online (Sandbox Code Playgroud)

这将使它向右移动,但是如果我尝试添加旋转,它也不起作用,否则它会崩溃. …

android

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

android ×1