久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 Android 中實現富文本編輯器?

Implementing a rich text editor in Android?(在 Android 中實現富文本編輯器?)
本文介紹了在 Android 中實現富文本編輯器?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我想知道是否有任何好的選擇可以在 Android 中實現 富文本編輯器.請注意,我說的是可以在 Android 應用程序中使用的富文本編輯器,而不是使用 HTML 和 Javascript 嵌入網頁中的編輯器.

I am wondering if there are any good options to implement a rich text editor in Android. Please note I am talking about a rich text editor that can be used in an Android application, not the one embedded in a web page using HTML and Javascript.

我的要求是:

  • 基本格式(顏色、字體、突出顯示、粗體、斜體、下劃線等)
  • 超鏈接
  • 內嵌圖片
  • 項目符號列表和編號列表
  • 內嵌表格(只有單元格內的內容是可編輯的,而不是表格結構)

如您所見,這與 Windows 上的典型 RichEdit 控件非常相似.

As you can see, this is pretty much something quite similar to a typical RichEdit control on Windows.

以下是我迄今為止所做的一些努力(調查和原型設計):

Here are some efforts (investigation & prototyping) I have made so far:

我嘗試使用 WebView 控件加載一個帶有 .內容變得可編輯,因為它是 HTML,我想它可以滿足我的大部分要求.但它有幾個問題:

I have tried using a WebView control to load an HTML fragment with one . The content becomes editable and as it is HTML, I suppose it can meet most of my requirements. But it has several issues:

  • (致命)沒有文本插入符號.用戶將不知道他/她輸入的字符將被插入到哪里.
  • 默認情況下,屏幕軟鍵盤是不可見的.有一個技巧,用戶必須長按菜單按鈕才能調出鍵盤.但我認為這是一個非常糟糕的用戶體驗.此外,屏幕布局未正確重新排列,文本插入點有時會被鍵盤覆蓋.

我嘗試過使用 EditText 控件.它似乎支持某種程度的富文本編輯(顏色、字體、粗體、斜體、下劃線、內嵌圖像、項目符號列表).但我仍然無法弄清楚如何實現以下要求:

I have tried using the EditText control. It seems to support some level of rich text editing (color, fonts, bold, italic, underline, inline images, bullet lists). But I still cannot figure out how I can implement the following requirements:

  • 控制項目符號符號的外觀(點、圓、破折號、箭頭、星號等)
  • 編號列表(1.、2.、3. 等)
  • 表格

順便說一句,我已經看到那里有幾個 *Span 類,但我不確定它們是否可以提供任何幫助......以及 http://developer.android.com 沒有提供太多有用的信息.

BTW, I have seen there are several *Span classes out there but I am not sure if they can be any help... And the http://developer.android.com does not provide much useful information about them.

那么,究竟如何在 Android 上實現富文本編輯器呢?我可以擴展 EditText 并添加我的新功能嗎?還是我應該從頭開始做一些事情 - 擴展視圖并自己實現一切?對于后面的選項(擴展視圖),我什至不知道如何顯示文本插入符號并使其閃爍,更不用說在用戶輸入時移動插入符號了.

So, how on earth can I implement a rich text editor on Android? Can I extends the EditText and add my new functionalities? Or should I do something from scratch - extends the View and implement everything by myself? For later option (extending View), I actually even don't know how to show a text caret and blink it, not mentionging moving the caret with user typing.

我現在很絕望……有什么提示嗎?

I am desperate now... Any hints?

謝謝!

-托尼

經過進一步調查,看起來擴展 EditText 是我最好的選擇.我不知何故想出了如何使用這些 Span 類,并猜測我應該能夠通過使用(擴展)它們來完成大部分技巧.

After some further investigation, it looks like extending EditText would be my best bet. I somehow figured out how to use those Span classes and guess I should be able to do most of the tricks by using (extending) them.

例如,擴展 BulletSpan 并覆蓋 drawLeadingMargin 應該可以讓我控制項目符號的外觀.擴展LeadingMarginSpan 應該對我的編號列表有所幫助.

For example, extending the BulletSpan and overriding drawLeadingMargin should give me the control of the bullet appereances. Extending the LeadingMarginSpan should help me on the numbered list.

對于表格,我最初的計劃是擴展 LineBackgroundSpan 并在 drawBackground 覆蓋中繪制所有表格邊框.但是,我仍然需要弄清楚如何布局表格單元格中的所有文本并正確處理插入符號的移動和選擇.有什么建議嗎?

As to the table, my initial plan is to extend the LineBackgroundSpan and draw all the table borders in the drawBackground override. However, I still need to figure out how to layout all the text in the table cells and properly handle the caret movement and selection. Suggestions?

推薦答案

我剛剛在 Apache 2.0 許可下發布了我的富文本編輯器組件:

I just published my rich text editor component under the Apache 2.0 license:

https://github.com/1gravity/Android-RTEditor

這篇關于在 Android 中實現富文本編輯器?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

EditText: Disable Paste/Replace menu pop-up on Text Selection Handler click event(EditText:禁用文本選擇處理程序單擊事件上的粘貼/替換菜單彈出)
Multiline EditText with Done SoftInput Action Label on 2.3(2.3 上帶有完成 SoftInput 操作標簽的多行 EditText)
How to detect the swipe left or Right in Android?(如何在 Android 中檢測向左或向右滑動?)
Prevent dialog dismissal on screen rotation in Android(防止在Android中的屏幕旋轉對話框解除)
How do I handle ImeOptions#39; done button click?(如何處理 ImeOptions 的完成按鈕點擊?)
How do you set EditText to only accept numeric values in Android?(您如何將 EditText 設置為僅接受 Android 中的數值?)
主站蜘蛛池模板: 国产一区二 | 在线成人免费视频 | 国产精品视频网址 | 久久精品国产一区 | 中文字幕在线观看一区 | 日本三级日产三级国产三级 | 国产精品高清在线 | 欧美成人猛片aaaaaaa | 亚洲+变态+欧美+另类+精品 | 亚洲精品乱码久久久久久按摩观 | 91久久精品一区二区二区 | 国产精品免费看 | 成人免费共享视频 | 精品影院 | av福利网站 | 久久精品久久久久久 | 天天操天天干天天透 | 中文字幕在线播放第一页 | 中文字幕在线精品 | 91看片网 | 男女在线免费观看 | 在线不卡视频 | 伊人看片 | 亚洲综合一区二区三区 | 午夜精品在线观看 | 国产精品色一区二区三区 | 国产久 | 日韩二三区 | 精品一区二区电影 | 久久久国产精品入口麻豆 | 黄色毛片免费 | 在线免费观看成人 | 国产精品免费在线 | www国产成人免费观看视频,深夜成人网 | 久久成人人人人精品欧 | 91久久久久久久久久久 | 久久精品成人热国产成 | 成人精品一区亚洲午夜久久久 | 国产精品久久 | 国产色在线 | 国产91久久久久久久免费 |