我成功地在我的Android应用程序项目中集成了以下库。这很好,感谢作者dankito!
但是,我想从工具栏中删除一些按钮。 (标题1 - 6,正文,预格式化,块指定,插入复选框..)
但我不明白该怎么做。它是用Kotlin写的。
是否可以简单地做到这一点?我卡住了......
我还想更改字符串以将它们翻译成法语。可能吗 ?
这是我显然无法修改的库的代码。
package net.dankito.richtexteditor.android.toolbar
import android.content.Context
import android.util.AttributeSet
import net.dankito.richtexteditor.android.command.*
class AllCommandsEditorToolbar : EditorToolbar {
constructor(context: Context) : super(context) { initToolbar() }
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) { initToolbar() }
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { initToolbar() }
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) { initToolbar() }
private fun initToolbar() {
addCommand(BoldCommand())
addCommand(ItalicCommand())
addCommand(UnderlineCommand())
addCommand(StrikeThroughCommand())
addCommand(SuperscriptCommand())
addCommand(SubscriptCommand())
addCommand(RemoveFormatCommand())
addCommand(UndoCommand())
addCommand(RedoCommand())
addCommand(BlockQuoteCommand())
addCommand(SetTextFormatCommand())
addCommand(SetFontNameCommand())
addCommand(SetFontSizeCommand())
addCommand(SwitchTextColorOnOffCommand())
addCommand(SetTextColorCommand())
addCommand(SwitchTextBackgroundColorOnOffCommand())
addCommand(SetTextBackgroundColorCommand())
addCommand(DecreaseIndentCommand())
addCommand(IncreaseIndentCommand())
addCommand(AlignLeftCommand())
addCommand(AlignCenterCommand())
addCommand(AlignRightCommand())
addCommand(AlignJustifyCommand())
addCommand(InsertBulletListCommand())
addCommand(InsertNumberedListCommand())
addCommand(InsertLinkCommand())
addCommand(InsertImageCommand())
addCommand(InsertCheckboxCommand())
addSearchView()
}
}
谢谢你的帮助
要修改库,您需要从Build.gradle
中删除当前库的依赖关系,然后将该库添加为Android Studio中的模块。
This answer已经解释了如何做到这一点。
关于您对库的修改,在initToolbar
方法(或者其他方法,取决于库实现),您需要删除库中的Button
(或任何您想要的)以及相关代码。
即:删除:addCommand(UndoCommand())
从库中删除UndoCommand
然后在库中查找相关代码并将其删除。