旋转Android中的视图 [英] Rotating a view in Android

查看:110
本文介绍了旋转Android中的视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,我想提出一个45度角的按钮。出于某种原因,我不能得到这个工作。

I have a button that I want to put on a 45 degree angle. For some reason I can't get this to work.

有人可以提供code做到这一点?

Can someone please provide the code to accomplish this?

推荐答案

您可以创建一个动画,并将其应用到您的按钮来查看。例如:

You could create an animation and apply it to your button view. For example:

    // Locate view
    ImageView diskView = (ImageView) findViewById(R.id.imageView3);

    // Create an animation instance
    Animation an = new RotateAnimation(0.0f, 360.0f, pivotX, pivotY);

    // Set the animation's parameters
    an.setDuration(10000);               // duration in ms
    an.setRepeatCount(0);                // -1 = infinite repeated
    an.setRepeatMode(Animation.REVERSE); // reverses each repeat
    an.setFillAfter(true);               // keep rotation after animation

    // Aply animation to image view
    diskView.setAnimation(an);

这篇关于旋转Android中的视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆