rich-text-android
所属分类:Python编程
开发工具:Java
文件大小:0KB
下载次数:0
上传日期:2019-02-18 07:46:16
上 传 者:
sh-1993
说明: 通过图像和视频轻松显示丰富的内容。以编程方式格式化内容或使用HTML字符串
(Easily show rich content, with images and videos. Format content programatically or use HTML string)
文件列表:
CODE_OF_CONDUCT.md (3215, 2019-02-17)
RichTextExample/ (0, 2019-02-17)
RichTextExample/build.gradle (1210, 2019-02-17)
RichTextExample/proguard-rules.pro (657, 2019-02-17)
RichTextExample/src/ (0, 2019-02-17)
RichTextExample/src/androidTest/ (0, 2019-02-17)
RichTextExample/src/androidTest/java/ (0, 2019-02-17)
RichTextExample/src/androidTest/java/io/ (0, 2019-02-17)
RichTextExample/src/androidTest/java/io/square1/ (0, 2019-02-17)
RichTextExample/src/androidTest/java/io/square1/richtext/ (0, 2019-02-17)
RichTextExample/src/androidTest/java/io/square1/richtext/ApplicationTest.java (3543, 2019-02-17)
RichTextExample/src/main/ (0, 2019-02-17)
RichTextExample/src/main/AndroidManifest.xml (989, 2019-02-17)
RichTextExample/src/main/assets/ (0, 2019-02-17)
RichTextExample/src/main/assets/fonts/ (0, 2019-02-17)
RichTextExample/src/main/assets/fonts/GreatVibes-Regular.otf (52928, 2019-02-17)
RichTextExample/src/main/assets/fonts/IndieFlower.ttf (61556, 2019-02-17)
RichTextExample/src/main/assets/fonts/SourceCodePro-Black.ttf (120356, 2019-02-17)
RichTextExample/src/main/assets/fonts/SourceCodePro-Bold.ttf (120504, 2019-02-17)
RichTextExample/src/main/assets/fonts/SourceCodePro-ExtraLight.ttf (121568, 2019-02-17)
RichTextExample/src/main/assets/fonts/SourceCodePro-Light.ttf (121284, 2019-02-17)
RichTextExample/src/main/assets/fonts/SourceCodePro-Medium.ttf (120244, 2019-02-17)
RichTextExample/src/main/assets/fonts/SourceCodePro-Regular.ttf (120548, 2019-02-17)
RichTextExample/src/main/assets/fonts/SourceCodePro-Semibold.ttf (120252, 2019-02-17)
RichTextExample/src/main/assets/fonts/Vegur-Bold.otf (15956, 2019-02-17)
RichTextExample/src/main/assets/fonts/Vegur-Light.otf (15300, 2019-02-17)
RichTextExample/src/main/assets/fonts/Vegur-Regular.otf (15248, 2019-02-17)
RichTextExample/src/main/assets/fonts/Velino_Text-Bold.otf (139252, 2019-02-17)
RichTextExample/src/main/assets/samples/ (0, 2019-02-17)
RichTextExample/src/main/assets/samples/html5.html (20425, 2019-02-17)
RichTextExample/src/main/assets/samples/test.html (1304, 2019-02-17)
RichTextExample/src/main/assets/samples/youtube_test.html (1449, 2019-02-17)
RichTextExample/src/main/java/ (0, 2019-02-17)
RichTextExample/src/main/java/io/ (0, 2019-02-17)
RichTextExample/src/main/java/io/square1/ (0, 2019-02-17)
RichTextExample/src/main/java/io/square1/richtext/ (0, 2019-02-17)
RichTextExample/src/main/java/io/square1/richtext/io/ (0, 2019-02-17)
... ...
# RichText Library
[ ![Download](https://api.bintray.com/packages/square1io/maven/richtext/images/download.svg) ](https://bintray.com/square1io/maven/richtext/_latestVersion)
Features
--------
- Display rich text using a fluent interface.
- Support Image loading from network.
- Parse HTML, including images and video tag into displayable content.
Download
--------
Use Gradle:
```gradle
repositories {
jcenter()
}
dependencies {
compile 'io.square1:richtext:x.x.x'
}
```
Setup a RichContentView
--------
Add a RichContentView to an xml layout, wrap around a ScrollView to enable content scrolling.
```xml
```
Enable Image download
--------
Supply an instance of a class that implements UrlImageDownloader instance and can download images
from the network:
```java
contentView.setUrlBitmapDownloader(new UrlBitmapDownloader() {
@Override
public void downloadImage(final RemoteBitmapSpan urlBitmapSpan, Uri image) {
Glide.with(activity)
.load(image)
.into(new BaseTarget
() {
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition super Drawable> transition) {
urlBitmapSpan.updateBitmap(activity, resource);
}
@Override
public void getSize(@NonNull SizeReadyCallback cb) {
cb.onSizeReady(urlBitmapSpan.getPossibleSize().width(), urlBitmapSpan.getPossibleSize().height());
}
@Override
public void removeCallback(@NonNull SizeReadyCallback cb) {
}
});
}
});
```
Enable click events
--------
Supply an instance of a clicked observer to receive on click events on parts of the content:
```java
contentView.setOnSpanClickedObserver(new RichContentViewDisplay.OnSpanClickedObserver() {
@Override
public boolean onSpanClicked(ClickableSpan span) {
String action = span.getAction();
action = TextUtils.isEmpty(action) ? " no action" : action;
Toast.makeText(getContext(), action, Toast.LENGTH_LONG).show();
return true;
}
});
```
Parse and display of HTML
--------
```java
String html = "This text is italic
";
RichTextDocumentElement element = RichTextV2.textFromHtml(context, html);
contentView.setText(element);
```
Sample Fluent Interface to create formatted text
--------
```java
String paragraph = getResources().getString(R.string.sample_text);
RichTextDocumentElement element = new RichTextDocumentElement
.TextBuilder("What is Lorem Ipsum")
.bold()
.color(Color.BLUE)
.underline(true)
.sizeChange(1.5f)
.center()
.newLine()
.image("https://netdna.webdesignerdepot.com/uploads/2013/07/icons-animation.gif",10,10)
.click("You have clicked on the image at the top!")
.newLine()
.append("Click the Image above")
.font("fonts/SourceCodePro-Bold.ttf")
.center()
.bold()
.sizeChange(1.5f)
.color(Color.RED)
.newLine()
.append(paragraph)
.left()
.image("http://random-ize.com/lorem-ipsum-generators/lorem-ipsum/lorem-ipsum.jpg")
.click("You have clicked on the image in the middle of the text")
.append("Click the lorem ipsum image")
.font("fonts/GreatVibes-Regular.otf")
.center()
.bold()
.sizeChange(1.5f)
.color(Color.RED)
.newLine()
.video("http://html5demos.com/assets/dizzy.mp4")
.append("It has survived not only five centuries,")
.color(Color.GRAY)
.sizeChange(2.0f)
.center()
.append("but also the leap into electronic typesetting,")
.strikethrough(true)
.append("remaining essentially unchanged.")
.click("Hello you have clicked on the text")
.bold()
.italic()
.build();
contentView.setText(element);
```
![sample](resources/sample-text-rendered.gif?raw=true)
License
--------
RichText is licensed under the Apache v2 license:
Copyright 2017 www.square1.io
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.
近期下载者:
相关文件:
收藏者: