我正在尝试使用RotationAnimation来移动ImageButton。我已经扩展了ImageButton以覆盖onAnimationEnd以避免动画结束时的屏幕闪烁,并且想要更新实际按钮的位置[因为动画只是一个表面的移动]。如何在动画结束时确定按钮的确切坐标?附件是我的一些代码.. 谢谢您的帮助!如果您需要更多详细信息,请与我们联系。
public class HomeNavigationButton extends ImageButton {
public HomeNavigationButton(Context context, AttributeSet attrs,
int defStyle) {
super(context, attrs, defStyle);
}
public HomeNavigationButton(Context context, AttributeSet attrs) {
super(context, attrs);
}
public HomeNavigationButton(Context context) {
super(context);
}
@Override
protected void onAnimationEnd() {
super.onAnimationEnd();
int l = ?
int t = ?
int r = ?
int b = ?
this.layout(l,t,r,b);
}
答案 0 :(得分:0)
按钮动画的位置?我会站出来,猜你不能。动画很有趣。他们不是“真实的”。把它们想象成海市蜃楼。试试这个。慢慢旋转图像。如果图像是矩形,当图像大约为45度时,单击图像所在的位置,但不长。你实际上会注册一个点击,因为图像实际上 正在以实际坐标旋转。
我会考虑实际上像按钮精灵一样动画按钮,或者对动画做一些试验和错误并手动设置值。如果你做第二个,请确保动态转换为DIP坐标而不是原始的int。