ANDROID JAVA以度数方向移动控制

时间:2015-03-30 10:04:50

标签: java android imageview move degrees

如何以度数移动特定方向的控件(例如ImageView)。没有控件需要停止移动的坐标。我们想以度数(0-360)的方向移动它

这不起作用:

RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

        params.setMargins(100,75, 0,0);
        params.topMargin= 100;

1 个答案:

答案 0 :(得分:0)

找到解决方案,就是这样: Sinus是解决方案......

RelativeLayout root = (RelativeLayout) findViewById( R.id.rootLayout );
int originalPos[] = new int[2];
bal.getLocationOnScreen( originalPos );

Double sin = (Math.sin(Math.toRadians(degrees)) * (root.getHeight() / 2 )) / Math.sin(Math.toRadians(90 - degrees));
相关问题