Coder Social home page Coder Social logo

richtexteditor's Introduction

RichTextEditor

Android 下的富文本编辑器

Features

  • Redo
  • Undo
  • Bold
  • Bullet
  • Clear
  • Italic
  • Quote
  • Underline
  • StrikeThrough
  • Link

Use Glide 4 lib. Support gif

Screenshots

http://biuugames.huya.com/rich_text_editor_preview.gif

How to

Step 1. Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

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

Step 2. Add the dependency

dependencies {
    compile 'com.github.huzhenjie:RichTextEditor:1.0.4'
}

Example

In your layout

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@id/tools"
    android:layout_alignParentTop="true"
    android:fillViewport="true">

    <com.scrat.app.richtext.RichEditText
        android:id="@+id/rich_text"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/transparent"
        android:gravity="top|start"
        android:paddingEnd="16dp"
        android:paddingLeft="16dp"
        android:paddingRight="16dp"
        android:paddingStart="16dp"
        android:paddingTop="16dp"
        android:scrollbars="vertical"
        app:bulletColor="#FF2196F3"
        app:bulletGapWidth="8dp"
        app:bulletRadius="2dp"
        app:historyEnable="true"
        app:historySize="99"
        app:linkColor="#FF2196F3"
        app:linkUnderline="true"
        app:quoteCapWidth="2dp"
        app:quoteColor="#FF2196F3"
        app:quoteStripeWidth="8dp" />
</ScrollView>

In your Activity

RichEditText richEditText = (RichEditText) findViewById(R.id.rich_text);
richEditText.fromHtml(yourHtmlStr);

Image

richEditText.image(imageUri);

Bold

richEditText.bold(!richEditText.contains(RichEditText.FORMAT_BOLD));

Italic

richEditText.italic(!richEditText.contains(RichEditText.FORMAT_ITALIC));

Underline

richEditText.underline(!richEditText.contains(RichEditText.FORMAT_UNDERLINED));

Bullet

richEditText.bullet(!richEditText.contains(RichEditText.FORMAT_BULLET));

Quote

richEditText.quote(!richEditText.contains(RichEditText.FORMAT_QUOTE));

More example click here

Important

1.0.3 Glide version 4.3.0
1.0.2 Glide version 3.7.0

richtexteditor's People

Contributors

huzhenjie avatar

Watchers

James Cloos avatar  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.