ExtendEditText是基于EditText的文本编辑器, 只要一行代码就更改文本的样式.
compile 'com.leo.extendedittext:library:0.1.1'
<com.leo.extendedittext.ExtendEditText
android:id="@+id/extend_edit_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:textSize="@dimen/normal_text_size"
android:scrollbars="none"
android:background="@android:color/transparent"
app:bulletColor="@color/colorPrimary" // 着重号颜色
app:bulletRadius="@dimen/bullet_radius" // 着重号半径
app:bulletGapWidth="@dimen/bullet_gap_width" // 着重号与文本的宽度
app:quoteColor="@color/colorPrimary" // 引用颜色
app:quoteStripeWidth="@dimen/quote_stripe_width" // 引用宽度
app:quoteGapWidth="@dimen/quote_gap_width" // 引用与文本的宽度
app:linkColor="@color/colorPrimaryDark" // 链接颜色
app:drawUnderLine="true" // 链接是否画下划线
app:enableHistory="true" // 是否开启历史记录
app:historyCapacity="50" // 历史记录容量
app:rule="EXCLUSIVE_EXCLUSIVE"> // 规则,后面说
</com.leo.extendedittext.ExtendEditText>
选中文本,调用相应的接口,所选文本就会更换样式。
mExtendEdt.bold(); // 粗体
mExtendEdt.italic(); // 斜体
mExtendEdt.underline(); // 下划线
mExtendEdt.strikethrough(); // 删除线
mExtendEdt.link(); // 链接
mExtendEdt.bullet(); // 着重号
mExtendEdt.quote(); // 引用
- bold
- italic
- underline
strikethrough- link
-
- bullet
-
quote
- insert image
- background color
Copyright (C) 2017 Leo Wu
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.