ANDROID JAVA方向的移动度控制 [英] ANDROID JAVA move control in direction in degrees
本文介绍了ANDROID JAVA方向的移动度控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何移动在度一定direcion的控制(例如ImageView的)。有没有协调,其中控制需要停止移动。我们希望它在移动度的方向(0-360)
这不工作:
RelativeLayout.LayoutParams PARAMS =新RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT); params.setMargins(100,75,0,0);
params.topMargin = 100;
解决方案
找到了解决办法,这是它:
窦是解决...
RelativeLayout的根=(RelativeLayout的)findViewById(R.id.rootLayout);
INT originalPos [] =新INT [2];
bal.getLocationOnScreen(originalPos);双罪=(Math.sin(Math.toRadians(度))*(root.getHeight()/ 2))/ Math.sin(Math.toRadians(90 - 度));
How do you move an control (for example a ImageView) in a certain direcion in degrees. There is no coordinate where the control needs to stop moving. we want to move it in a direction in degrees (0-360)
This doesn't work:
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
params.setMargins(100,75, 0,0);
params.topMargin= 100;
解决方案
Found the solution, this is it: Sinus was the solution...
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));
这篇关于ANDROID JAVA方向的移动度控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文