android項目實戰之編輯器集成

引言

項目需要用到編輯器,采用RichEditor,如下效果

實現

1.?引入庫2

implementation 'jp.wasabeef:richeditor-android:2.0.0'

2.? XML

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"android:layout_marginBottom="@dimen/dp_60"android:theme="@style/customTheme"><HorizontalScrollViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:background="@color/app_color_9b"><LinearLayoutandroid:orientation="horizontal"android:layout_width="wrap_content"android:layout_height="wrap_content"><ImageButtonandroid:id="@+id/action_undo"android:layout_width="48dp"android:layout_height="48dp"android:background="@null"android:contentDescription="@null"android:src="@mipmap/undo" /><ImageButtonandroid:id="@+id/action_redo"android:layout_width="48dp"android:layout_height="48dp"android:background="@null"android:contentDescription="@null"android:src="@mipmap/redo" /><ImageButtonandroid:id="@+id/action_bold"android:layout_width="48dp"android:layout_height="48dp"android:background="@null"android:contentDescription="@null"android:src="@mipmap/bold" /><ImageButtonandroid:id="@+id/action_heading1"android:layout_width="48dp"android:layout_height="48dp"android:background="@null"android:contentDescription="@null"android:src="@mipmap/h1" /><ImageButtonandroid:id="@+id/action_heading2"android:layout_width="48dp"android:layout_height="48dp"android:background="@null"android:contentDescription="@null"android:src="@mipmap/h2" /><ImageButtonandroid:id="@+id/action_heading3"android:layout_width="48dp"android:layout_height="48dp"android:background="@null"android:contentDescription="@null"android:src="@mipmap/h3" /><ImageButtonandroid:id="@+id/action_heading4"android:layout_width="48dp"android:layout_height="48dp"android:background="@null"android:contentDescription="@null"android:src="@mipmap/h4" /><ImageButtonandroid:id="@+id/action_heading5"android:layout_width="48dp"android:layout_height="48dp"android:background="@null"android:contentDescription="@null"android:src="@mipmap/h5" /><ImageButtonandroid:id="@+id/action_heading6"android:layout_width="48dp"android:layout_height="48dp"android:background="@null"android:contentDescription="@null"android:src="@mipmap/h6" /><ImageButtonandroid:id="@+id/action_insert_image"android:layout_width="48dp"android:layout_height="48dp"android:background="@null"android:contentDescription="@null"android:src="@mipmap/insert_image" /></LinearLayout></HorizontalScrollView><androidx.core.widget.NestedScrollViewandroid:layout_width="match_parent"android:layout_height="wrap_content"><jp.wasabeef.richeditor.RichEditorandroid:id="@+id/editor"android:layout_width="match_parent"android:layout_height="wrap_content" /></androidx.core.widget.NestedScrollView><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="詳情預覽"android:visibility="gone"android:textSize="12sp" /><TextViewandroid:id="@+id/preview"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="15dp"android:visibility="gone"/></LinearLayout>

3. fragement片段初始化

 private void initEditor(){mPreview = (TextView) mActivity.findViewById(R.id.preview);mEditor = (RichEditor) mActivity.findViewById(R.id.editor);//初始化編輯高度mEditor.setEditorHeight(200);//初始化字體大小mEditor.setEditorFontSize(16);//初始化字體顏色mEditor.setEditorFontColor(Color.BLACK);//初始化內邊距mEditor.setPadding(10, 10, 10, 10);//設置默認顯示語句mEditor.setPlaceholder("請輸入...");//設置編輯器是否可用mEditor.setInputEnabled(true);//mPreview = (TextView) mActivity.findViewById(R.id.preview);mEditor.setOnTextChangeListener(new RichEditor.OnTextChangeListener() {@Overridepublic void onTextChange(String text) {mPreview.setText(text);}});mActivity.findViewById(R.id.action_undo).setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {mEditor.undo();}});mActivity.findViewById(R.id.action_redo).setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {mEditor.redo();}});mActivity.findViewById(R.id.action_heading1).setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {mEditor.setHeading(1);}});mActivity.findViewById(R.id.action_heading2).setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {mEditor.setHeading(2);}});mActivity.findViewById(R.id.action_heading3).setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {mEditor.setHeading(3);}});mActivity.findViewById(R.id.action_heading4).setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {mEditor.setHeading(4);}});mActivity.findViewById(R.id.action_heading5).setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {mEditor.setHeading(5);}});mActivity.findViewById(R.id.action_heading6).setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {mEditor.setHeading(6);}});

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/208450.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/208450.shtml
英文地址,請注明出處:http://en.pswp.cn/news/208450.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

LeetCode:2008. 出租車的最大盈利(dp C++)

目錄 2008. 出租車的最大盈利 題目描述&#xff1a; 實現代碼與解析&#xff1a; DP 二分&#xff08;兩種寫法&#xff09; 原理思路&#xff1a; 2008. 出租車的最大盈利 題目描述&#xff1a; 你駕駛出租車行駛在一條有 n 個地點的路上。這 n 個地點從近到遠編號為 1 …

如何使用 Wordpress?托管, 網站, 插件, 緩存

這是該系列教程的第一個教程&#xff0c;最終將在運行高性能 LEMP 堆棧的阿里云 ECS 實例上運行一個新的 WordPress 站點。 在本教程中&#xff0c;我們將創建一個運行 Ubuntu 16.04 的實例&#xff0c;然后通過創建超級用戶并禁用 root 登錄來保護服務器&#xff0c;最后配置…

持續集成交付CICD:使用Maven命令下載Nexus制品

目錄 一、實驗 1.Maven安裝 2.Nexus搭建公共組倉庫及Maven全局配置文件 3.使用Maven命令下載Nexus制品 一、實驗 1.Maven安裝 &#xff08;1&#xff09;CentOS環境安裝步驟 tar -xf apache-maven-3.8.6-bin.tar.gz #解壓 mv apache-maven-3.8.6 /usr/local/maven #移動…

如何進行更好的面試回復之緩存函數在項目中的性能優化?

緩存函數是一種提高函數性能的技術&#xff0c;在函數被調用時&#xff0c;會將計算結果緩存起來&#xff0c;以便在后續的調用中直接返回緩存的結果&#xff0c;從而減少了重復計算的時間。 緩存函數的實現通常包括兩個步驟&#xff1a; 判斷緩存是否存在&#xff1a;在函數被…

提取視頻光流成幀并寫入視頻中

修改一下配置文件就可以運行了 配置文件 config.py video_path xxxx/dataset/data/huaping/BXDQ05-花屏-1.mp4#要處理的視頻路徑 frame_path xxxx/dataset/frame#處理成幀之后保存的路徑 flow_path xxxx/dataset/flow#處理成光流之后保存的路徑 save_video_path xxxx/fe…

自動補全的 select antd react

自動補全的 select antd react 文檔&#xff1a;自動補全的 select antd react.note 鏈接&#xff1a;http://note.youdao.com/noteshare?idf5e4a93d2b9d6be8e459edd4eb86323b&sub19796E9BC04D4ABD9ACE325FDFF59B0E 添加鏈接描述 import React, { useState, useRef } from…

【1day】泛微e-office OA系統xml.php 文件 SORT_ID 參數 SQL 注入漏洞學習

注:該文章來自作者日常學習筆記,請勿利用文章內的相關技術從事非法測試,如因此產生的一切不良后果與作者無關。 目錄 一、漏洞描述 二、影響版本 三、資產測繪 四、漏洞復現

理解傳統模式與互聯網時代 消費行為模型 AIDMA , AISAS , SICAS

1 AIDMA與AISAS 消費行為模型&#xff0c;以及所誕生的IT崗位 1.1 傳統市場營銷消費行為模型 AIDMA模型&#xff1a;Attention&#xff08;吸引&#xff09;&#xff0c;Interest &#xff08;興趣&#xff09;&#xff0c;Desire&#xff08;欲望&#xff09; &#xff0c;Me…

LeetCode 76. 最小覆蓋子串 滑動窗口框架

雙指針的特殊應用&#xff1a;滑動窗口 代碼 題目鏈接&#xff1a;https://leetcode.cn/problems/minimum-window-substring/description/ 不說廢話&#xff0c;直接貼代碼&#xff1a; static string minWindow(string s, string t) {// need記錄需要匹配的字符串t中每個字…

? Mac IDEA使用并運行項目

? IDEA導入項目并運行 Mac IDEA使用 (1) 倉庫導入 通過獲取giett倉庫包的url&#xff0c;在idea中導入項目 在gitee里獲取項目的ur打開idea&#xff0c;點擊 File->new->Project from Version Control (2) 創建數據庫ry并導入數據腳本 &#xff08;3&#xff09;修改配…

華為配置Smart Link主備備份示例

定義 Smart Link&#xff0c;又叫做備份鏈路。一個Smart Link由兩個接口組成&#xff0c;其中一個接口作為另一個的備份。Smart Link常用于雙上行組網&#xff0c;提供可靠高效的備份和快速的切換機制。 Monitor Link是一種接口聯動方案&#xff0c;它通過監控設備的上行接口…

npm私有源構建項目下載依賴報錯

Jenkins構建項目報錯&#xff0c;依賴找不到 Error: Couldnt find any versions for "babel/helper-module-imports" that matches "^7.22.15"at MessageError.ExtendableBuiltin (/data1/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/…

log4j(日志的配置)

日志一般配置在resources的config下面的&#xff0c;并且Util當中的initLogRecord中的initLog&#xff08;&#xff09;方法就是加載這個log4j.properties的. 首先先看log4j.properties的配置文件 log4j.rootLoggerdebug, stdout, Rlog4j.appender.stdoutorg.apache.log4j.Co…

高性能和多級高可用,云原生數據庫 GaiaDB 架構設計解析

1 云原生數據庫和 GaiaDB 目前&#xff0c;云原生數據庫已經被各行各業大規模投入到實際生產中&#xff0c;最終的目標都是「單機 分布式一體化」。但在演進路線上&#xff0c;當前主要有兩個略有不同的路徑。 一種是各大公有云廠商選擇的優先保證上云兼容性的路線。它基于存…

考研真題數據結構

【2021年山西大學真題】將二叉樹中所有非終端結點的左右子樹交換位置&#xff0c;可以得到原二叉樹的 鏡像二叉樹&#xff0c;如圖。假設二叉樹的存儲形式為&#xff08;lchild&#xff0c;data&#xff0c;rchild&#xff09;&#xff0c;給出求鏡像二叉樹的算法: &#xff0…

Sql Server Management Studio連接Mysql

目標 已知mysql連接參數&#xff08;地址和用戶&#xff09;&#xff0c;期望通過Microsoft Sql Server Management Studio &#xff08;以下簡稱MSSSMS&#xff09;連接Mysql&#xff0c;在MSSSMS中直接查詢或修改Mysql中的數據。 下載MySql Connector/ODBC并安裝&#xff0c…

使用poi-tl填充word模板,并轉化為pdf輸出

后端 依賴 <dependency><groupId>com.deepoove</groupId><artifactId>poi-tl</artifactId><version>1.12.0</version> </dependency>Word版本 Word版本填充代碼 // 培訓詳情HashMap<String, Object> textMap new Ha…

maven環境搭建

maven歷史版本下載&#xff1a;https://archive.apache.org/dist/maven/ 新建系統變量編輯Path&#xff0c;添加bin目錄mvn -v測試查看版本號conf目錄下新建repository文件夾&#xff0c;作為本地倉庫 settings.xml <?xml version"1.0" encoding"UTF-8&…

2312d,d語言來綁定C++和rust

原文 各編譯語言相同概念 1,按可重用函數拆分代碼. 2,由源碼中的函數名生成的串來標識函數.如,g為void foo()生成_Z3foov的標識.此串總是是可重現的;如,Linux上的Clang和GCC都遵循ItaniumCABI約定來裝飾函數名. 3,在內存中的特定位置存儲該函數的所有參數,然后用調用或等效指…

gitee配置

注冊配置gitee Gitee官網 進入官網之后&#xff0c;有賬號直接登錄&#xff0c;沒有賬號注冊一個新的賬號 下載安裝git客戶端 官網地址 下載完成&#xff0c;一路直接點擊安裝直接安裝成功 檢查是否安裝成功 鼠標留在桌面–>右擊–>出現Git GUI Here/Git Bash Her…