A custom editor for Android - a simple WYSIWYG. You can set Bold, Italic, Underline and Color.
The color picker library is AmbilWarna and you can find it here: https://code.google.com/p/android-color-picker/ or here https://github.com/yukuku/ambilwarna
This library is extended from EditText, so you can get the output as HTML with toHtml()
or set it from HTML code by using Html.fromHtml()
or getTextHTML()
. But the HTML format will be like this
<b><i><u><font color="#FF0000">Hello world</font></u><i><b>
Because Android doesn't support CSS style for TextView, see this article for more.
Import to Eclipse
File->Import->Existing Projects into Workspace
Reference this lib to your project
Right Click on your project -> Properties -> Android -> Add -> <<Select AmbilWarna & CustomEditor>>
Step 1. Add the JitPack repository to your build file build.gradle
with:
repositories {
maven { url "https://jitpack.io" }
}
and:
dependencies {
compile 'com.github.trietphm:CustomEditor:v1.0.1'
}
Step 1: Add CustomEditor view element in your layout.xml
<windyzboy.github.io.customeeditor.CustomEditText
android:id="@+id/CustomEditor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top"
android:inputType="textFilter|textMultiLine|textNoSuggestions"
android:minLines="10" >
</windyzboy.github.io.customeeditor.CustomEditText>
Step 2: Get the Object and use it as an EditText (CustomEditor extends from EditText)
CustomEditText customEditor = (CustomEditText) findViewById(R.id.CustomEditor);
There is a demo in folder Demo (Android Studio) or Eclipse project/CustomEditorDemo (Eclipse), see it for more detail.