1 Star 0 Fork 1

hihopeorg / AutoLinkTextView

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载

A permissive license whose main conditions require preservation of copyright and license notices. Contributors provide an express grant of patent rights. Licensed works, modifications, and larger works may be distributed under different terms and without source code.

Permissions
  • Commercial use
  • Modification
  • Distribution
  • Patent use
  • Private use
Limitations
  • Trademark use
  • Liability
  • Warranty
Conditions
  • License and copyright notice
  • State changes
README.md 4.17 KB
一键复制 编辑 原始数据 按行查看 历史
qiao_jianqiang 提交于 2021-11-06 09:58 . adaptive api version

AutoLinkTextView

本项目是基于开源项目AutoLinkTextView进行ohos化的移植和开发的,可以通过项目标签以及github地址(https://github.com/armcha/AutoLinkTextView )追踪到原项目版本

项目介绍

  • 项目名称:AutoLinkTextView
  • 所属系列:ohos的第三方组件适配移植
  • 功能:自动检测(#)标签,(@)标签,URL(http://),电话和电子邮件以及处理点击事件的功能
  • 项目移植状态:完成
  • 调用差异:无
  • 项目作者和维护人:hihope
  • 联系方式:hihope@hoperun.com
  • 原项目Doc地址:https://github.com/armcha/AutoLinkTextView
  • 原项目基线版本:v0.2.0, sha1:4749b1bb67a7ce260a87ff1ded79803f71c563a3
  • 编程语言:Java
  • 外部库依赖:无

效果展示

gif

安装教程

方法1.

  1. 编译library的har包autolinklibrary.har。
  2. 启动 DevEco Studio,将编译的har包,导入工程目录“entry->libs”下。
  3. 在moudle级别下的build.gradle文件中添加依赖,在dependences标签中增加对libs目录下har包的引用。
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
	……
}
  1. 在导入的har包上点击右键,选择“Add as Library”对包进行引用,选择需要引用的模块,并点击“OK”即引用成功。

方法2.

  1. 在工程的build.gradle的allprojects中,添加HAR所在的Maven仓地址
repositories {
    maven {
        url 'http://106.15.92.248:8081/repository/Releases/'
    }
}
  1. 在应用模块的build.gradle的dependencies闭包中,添加如下代码:
dependencies {
    implementation 'com.luseen.ohos:autolinklibrary:1.0.1'
}

使用说明

  1. gradle中添加依赖:
implementation 'com.luseen.ohos:autolinklibrary:1.0.1'
  1. 将控件添加在布局文件中:
<com.luseen.autolinklibrary.AutoLinkTextView
    ohos:id="$+id:active"
    ohos:height="match_content"
    ohos:width="match_content"
    ohos:multiple_lines="true"
    ohos:scrollable="true"
    ohos:text_color="$color:tertiary_text_dark"
    ohos:text_size="15fp"
    />
  1. 设置匹配模式
autoLinkTextView.addAutoLinkMode(
        AutoLinkMode.MODE_HASHTAG,
        AutoLinkMode.MODE_PHONE,
        AutoLinkMode.MODE_URL,
        AutoLinkMode.MODE_EMAIL,
        AutoLinkMode.MODE_MENTION);
  1. 设置颜色
autoLinkTextView.setHashtagModeColor(getColor(ResourceTable.Color_color2));
autoLinkTextView.setPhoneModeColor(getColor(ResourceTable.Color_color3));
autoLinkTextView.setCustomModeColor(getColor(ResourceTable.Color_color1));
autoLinkTextView.setMentionModeColor(getColor(ResourceTable.Color_color5));
  1. 设置文本和点击监听
autoLinkTextView.setText(getString(ResourceTable.String_long_text));

autoLinkTextView.setAutoLinkOnClickListener(new AutoLinkOnClickListener() {
    @Override
    public void onAutoLinkTextClick(AutoLinkMode autoLinkMode, String matchedText) {
        //
    }
});
  1. 粗体显示和下划线
autoLinkTextView.setBoldAutoLinkModes(
  AutoLinkMode.MODE_HASHTAG,
  AutoLinkMode.MODE_PHONE,
  AutoLinkMode.MODE_URL,
  AutoLinkMode.MODE_EMAIL,
  AutoLinkMode.MODE_MENTION
);

autoLinkTextView.enableUnderLine();
  1. 自定义匹配规则

    如果使用自定义模式,还应添加自定义正则表达式,否则MODE_CUSTOM会默认返回MODE_URL

autoLinkTextView.addAutoLinkMode(AutoLinkMode.MODE_CUSTOM);

autoLinkTextView.setCustomRegex("\\sAllo\\b");

版本迭代

  • 1.0.1

版权和许可信息

  Copyright (c) 2018 Arman Chatikyan (https://github.com/armcha/AutoLinkTextView).

  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.
1
https://gitee.com/hihopeorg/AutoLinkTextView.git
git@gitee.com:hihopeorg/AutoLinkTextView.git
hihopeorg
AutoLinkTextView
AutoLinkTextView
master

搜索帮助