5 Star 0 Fork 0

Archermind-TI / MovingButton

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 3.90 KB
一键复制 编辑 原始数据 按行查看 历史
zhouyuhang 提交于 2021-07-22 17:07 . update README.md

Moving Button

项目介绍

向八个方向移动的按钮。

效果演示

安装教程

方式一

  1. 下载模块代码添加到自己的工程

  2. 关联使用

dependencies {
implementation project(':library')
……
}

3.在系统的settings.gradle中添加

include ':entry',':library'

方式二:

  1. 在module的build.gradle中添加movingbutton的依赖
   dependencies {
       implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
       ……
       implementation 'com.gitee.archermind-ti:movingbutton:1.0.0'
   }
  1. 在project的build.gradle中添加mavenCentral()的引用
   allprojects {
       repositories {
           ……
           mavenCentral()
       }
   }

使用说明

监听:

    public interface OnPositionChangedListener {
        // returns MotionEvent action and changed button position
        void onPositionChanged(int action, ButtonPosition position);
    }

    movingButton.setOnPositionChangedListener(new MovingButton.OnPositionChangedListener() {
        @Override
        public void onPositionChanged(int action, ButtonPosition position) {
            //your code here
        }
    });

xml 引用:

<com.thefinestartist.library.movingbutton_ohos.MovingButton
    ohos:id="$+id:moving_button"
    xmlns:app="http://schemas.huawei.com/apk/res/ohos"
    ohos:height="40vp"
    ohos:width="110vp"
    ohos:auto_font_size="false"
    ohos:background_element="#FF0C0B0B"
    ohos:bottom_margin="30vp"
    ohos:layout_alignment="vertical_center"
    ohos:left_margin="125vp"
    ohos:text="move"
    ohos:text_color="#FFFFFF"
    ohos:text_size="16vp"
    ohos:top_margin="15vp"
    app:mb_event_volume="50"
    app:mb_move_direction="all"
    app:mb_movement="10vp"
    app:mb_vibration_duration="20"
/>
    // Move Direction
    movingButton.getMoveDirection();
    movingButton.setMoveDirection(MoveDirection.ALL);

    // Movement (in Pixel dimension)
    movingButton.getMovement();
    movingButton.setMovement(10);
    movingButton.getMovementLeft();
    movingButton.setMovementLeft(10);
    movingButton.getMovementRight();
    movingButton.setMovementRight(10);
    movingButton.getMovementTop();
    movingButton.setMovementTop(10);
    movingButton.getMovementBottom();
    movingButton.setMovementBottom(10);

    // Offset (in Pixel dimension)
    movingButton.getOffSetInner();
    movingButton.setOffSetInner(10);
    movingButton.getOffSetOuter();
    movingButton.setOffSetOuter(10);

    // Vibration
    movingButton.getVibrationDuration();
    movingButton.setVibrationDuration(20);

    // Volume
    movingButton.getEventVolume();
    movingButton.setEventVolume(50);

    // Current Position
    movingButton.getCurrentPosition();

版本迭代

  • v1.0.0

License

The MIT License (MIT)

Copyright (c) 2015 TheFinestArtist

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
1
https://gitee.com/archermind-ti/MovingButton.git
git@gitee.com:archermind-ti/MovingButton.git
archermind-ti
MovingButton
MovingButton
master

搜索帮助