GithubHelp home page GithubHelp logo

shaohui93 / textselectionbar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yvescheung/textselectionbar

0.0 0.0 0.0 3.22 MB

Drag the bar to move the cursor position of the Android EditText

License: Apache License 2.0

Kotlin 100.00%

textselectionbar's Introduction

TextSelectionBar

🔍 Android长文本输入栏神器!

📏 通过拖动进度条移动光标或选中文本。

Build

Preview

短按拖动:移动光标 长按拖动:选中文本

Feature

  1. 支持 短按移动长按选中短按选中长按移动仅移动光标仅选中文本 四种模式。

  2. 可选开启放大镜

  3. 可选开启“剪切/复制/粘贴/全选”菜单。

Usage

一行完成接入

Ui使用系统原生的 EditTextSeekBar,样式由使用方自行实现。 本库只负责控制逻辑。

TextSelectionController(editText).attachTo(seekBar)

更多可选配置

val controller = TextSelectionController(
    target = editText, 
    mode = Mode.ShortPressMoveAndLongPressSelection, //短按移动,长按选中
    enableWhen = EnableWhen.NotEmpty, //只有EditText非空才可用
    startActionModeAfterSelection = true, //选中后是否显示“剪切/复制”菜单
    enableMagnifier = true //是否开启放大镜,Android9+支持
)
controller.moveSensitivity = 100f //值越大,拖动进度条时光标移动越快
controller.longPressDuration = 500L //手势多长时间算长按
controller.moveCursorDuration = 100L //当进度条拖到尽头后,每隔多长时间移动一次光标
controller.attachTo(seekBar)

Install

allprojects {
    repositories {
        //...
        maven { url 'https://jitpack.io' }
    }
}

dependencies {
    implementation 'com.github.YvesCheung:TextSelectionBar:x.y.z'
}

x.y.z replace with

License

Copyright 2022 Yves Cheung

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   	http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

textselectionbar's People

Contributors

yvescheung avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.