Giter Site home page Giter Site logo

dypcode / spannable Goto Github PK

View Code? Open in Web Editor NEW

This project forked from liangjingkanji/spannable

0.0 0.0 0.0 1.15 MB

Android最好的Spannable构建工具, 目前唯一支持正则匹配/图文混排/GIF动画/自适应文字

License: Apache License 2.0

Java 11.49% Kotlin 88.51%

spannable's Introduction

Spannable和创建字符串一样简单



下载体验



本工具真正实现让Spannable和String一样易用, 快速实现常见的图文列表/图文混排/表情包需求/文字换行, 同时也是全网第一个实现正则替换和最完美实现图文混排的Span工具, 对于MVVM架构更是如虎添翼, 数据和视图解耦

特点

  • 低学习成本
  • 首个支持替换/正则/捕获组Span的库
  • 全部使用CharSequence接口, 使用起来和字符串没有区别
  • 没有自定义控件/没有多余函数
  • 快速实现图文混排/富文本/自定义表情包
  • 输入框富文本/表情包

函数

使用的函数非常简单

函数 介绍
setSpan 设置Span
addSpan 添加/插入Span或字符串
replaceSpan 替换/正则替换Span或字符串
replaceSpanFirst/replaceSpanLast 替换/正则替换第一个/最后一个匹配项的Span或字符串

Span

本框架会收集一些常用的Span效果实现, 欢迎贡献代码

Span 描述
CenterImageSpan 垂直对齐方式/图片宽高/固定图片比例/显示文字/自适应文字宽高/Shape/.9图
GlideImageSpan 网络图片/GIF动画/垂直对齐方式/图片宽高/固定图片比例/显示文字/自适应文字宽高, Require Glide
MarginSpan 文字间距
ColorSpan 快速创建文字颜色
HighlightSpan 创建字体颜色/字体样式/可点击效果
ClickableMovementMethod 等效LinkMovementMethod, 但没有点击背景色

本工具将保持简单和扩展性, 如果你想使用dsl构建span可以使用SpannableX

安装

添加远程仓库根据创建项目的 Android Studio 版本有所不同

Android Studio Arctic Fox以下创建的项目 在项目根目录的 build.gradle 添加仓库

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

Android Studio Arctic Fox以上创建的项目 在项目根目录的 settings.gradle 添加仓库

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

然后在 module 的 build.gradle 添加依赖框架

implementation 'com.github.liangjingkanji:spannable:1.2.3'

License

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.

spannable's People

Contributors

liangjingkanji avatar txca avatar ismartcoding 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.