Android Custom Joystick

Source: Internet
Author: User
Tags call back

Reprint please explain the source!
KQW Siege Lion
Source: Personal Station | CSDN

Source

Kqwrockerdemo

Like to give a star , thank you!

Function
    • Supports adaptive size
    • Supports 2-direction, 4-direction, 8-directional shaking monitoring
    • Support for shaking angle acquisition
    • Optional callback mode
    • Support for customizable zone-shaking
    • Support Joystick Customization
    • Supports setting pictures, color values, shape shapes
Use
<kong.qingwei.rockerlibrary.RockerView    android:id="@+id/rockerView_center"    android:layout_width="100dp"    android:layout_height="100dp"    android:layout_centerHorizontal="true"    kongqw:areaBackground="#FF333333"    kongqw:rockerBackground="#FF987654"    kongqw:rockerRadius="15dp" />
Parameters
Parameters whether you must Description
Areabackground Options available The background of the area that can be shaken
Rockerbackground Options available The background of the joystick
Rockerradius Options available Joystick radius
Set Callback Mode
setCallBackMode(CallBackMode mode)

Parameters

callback Method Description
Call_back_mode_move Call back as soon as you have a move
Call_back_mode_state_change Callback when there is a change in state
Monitor Shake angle

Returns the range of values for the angle: [0°,360°]

setOnAngleChangeListener(OnAngleChangeListener listener)
Monitoring the direction of shaking
setOnShakeListener(DirectionMode directionMode, OnShakeListener listener)

Support the direction of monitoring

direction Figure Description
Direction_2_horizontal About two directions across the landscape
Direction_2_vertical Up and down two vertical directions
Direction_4_rotate_0 Four Directions
Direction_4_rotate_45 Swivel 45° in four directions
Direction_8 Eight directions

Direction description

direction Description
Direction_left Left
Direction_right Right
Direction_up On
Direction_down Under
Direction_up_left Upper left
Direction_up_right Top Right
Direction_down_left Lower left
Direction_down_right Lower right
Direction_center Middle
Example
Rockerview rockerviewleft = (rockerview) Findviewbyid (r.id.rockerview_left);if(Rockerviewleft! =NULL) {Rockerviewleft.setcallbackmode (RockerView.CallBackMode.CALL_BACK_MODE_STATE_CHANGE); Rockerviewleft.setonshakelistener (RockerView.DirectionMode.DIRECTION_8,NewRockerview.onshakelistener () {@Override         Public void OnStart() {Mlogleft.settext (NULL); }@Override         Public void direction(Rockerview.direction Direction) {Mlogleft.settext ("Shaking direction:"+ getdirection (direction)); }@Override         Public void onfinish() {Mlogleft.settext (NULL); }    });} Rockerview rockerviewright = (rockerview) Findviewbyid (r.id.rockerview_right);if(Rockerviewright! =NULL) {Rockerviewright.setonanglechangelistener (NewRockerview.onanglechangelistener () {@Override         Public void OnStart() {Mlogright.settext (NULL); }@Override         Public void Angle(DoubleAngle) {Mlogright.settext ("Shake angle:"+ angle); }@Override         Public void onfinish() {Mlogright.settext (NULL); }    });}

Android Custom Joystick

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.