GithubHelp home page GithubHelp logo

yaohf / richedittext Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kdf5000/richedittext

0.0 1.0 0.0 5.13 MB

一个基于Android原生EditText的富文本组件,可以添加文字,插入图片

License: Apache License 2.0

Java 100.00%

richedittext's Introduction

自定义的富文本组件

一个基于Android原生的EditText的富文本组件,支持文字输入,可以插入图片,并且会根据自动调整图片大小,宽度适应控件的宽度,高度等比例伸缩,图片支持本地图片和网络图片。

使用方法

该组件使用了一个开源的图片加载库ImageLoader,用于图片的同步和异步加载。所以使用该组件需要导入第三方库ImageLoader。然后将RichEditText.java拷贝自己的工程里,将需要使用富文本的地方替换为RichEditText

  • 输入文字和普通的EditText没有区别,主要是在插入图片的时候要进行处理
  • 插入图片时,需要将图片转化为Bitmap,然后指定其存储路径,调用addImage(bitmap,filePath),如下面的代码所示:
originalBitmap = ImageLoader.getInstance().loadImageSync(originalUri.toString());
contentRichEditText.addImage(originalBitmap,	getAbsoluteImagePath(originalUri));
  • 获取富文本的内容可以调用getRichText也可以调用getText().toString
其他功能

有时候我们可能需要对已经保存的文本进行编辑,那么就可以调用setRichEditText(content),content中的图片路径可以是本地路径,也可以是网路路径,但是一定要是<img src="path"/>的格式.

例子

详细使用方法可以参照sample下的例子,下面是例子的截图

1 2 3 4 5

richedittext's People

Contributors

kdf5000 avatar

Watchers

 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.