gcssloop / rocker Goto Github PK
View Code? Open in Web Editor NEW安卓虚拟摇杆
License: Apache License 2.0
安卓虚拟摇杆
License: Apache License 2.0
建议把界面刷新和消息回调的参数分开设置,或者把界面刷新时间写死,配置的时间间隔只用来控制回调频率
如何获取摇杆实时的位置呢?就是摇杆的具体坐标,我想根据用户拉的长度进行相应的逻辑处理。麻烦您解答一下,谢谢了。
经常会发现快速触摸松开不会发送angle=-1的状态,导致控制机器人不会停止,建议增加MotionEvent.ACTION_CANCEL ,这样就会减少错误发生,谢谢。
是根据角度确定方向的吗?
e.Log 能够成功运行,但是改成设置文本框内容的话,应用一启动就闪退。
activity_main.xml
<com.gcssloop.widget.RockerView
android:id="@+id/rocker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
rocker:area_background="#eee"
rocker:area_radius="80dp"
rocker:rocker_background="#fff"
rocker:rocker_radius="30dp"
tools:layout_editor_absoluteX="97dp"
tools:layout_editor_absoluteY="0dp" />
MainActiviuty.java
final TextView textView = (TextView) findViewById(R.id.textView);
RockerView rocker = (RockerView) findViewById(R.id.rocker);
if (null != rocker){
rocker.setListener(new RockerView.RockerListener() {
@Override
public void callback(int eventType, int currentAngle, float currentDistance) {
switch (eventType) {
case RockerView.EVENT_ACTION:
// 触摸事件回调
textView.setText("angle=" + currentAngle + " - distance" + currentDistance);
break;
case RockerView.EVENT_CLOCK:
// 定时回调
textView.setText("angle=" + currentAngle + " - distance" + currentDistance);
break;
}
}
});
}
如何使中间的摇杆圆坨只能在垂直方向上移动,也就是只有2个方向上和下方向?
注意不是,只监听上下2个方向.
能具体贴下代码吗?或加我QQ:2970308762联系.可捐助.非常希望您能帮我.谢谢
没有 com.gcssloop.view.utils.DensityUtils;
com.gcssloop.view.utils.MathUtils; 这两个文件
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.