支持日語假名注音的JpTextView
- 支持自動換行
- 支持自動寬高
- 支持一次標記或者總是標記
網上找了一下,發現沒有型別的輪子,就自己造了一個
原始碼:https://github.com/toukomine/JpTextView
引入依賴
代碼已上傳 mavenCentral倉庫,在專案根目錄的build.gradle的repositories節點加入以下代碼,新版AndroidStudio默認已添加
repositories {
...
mavenCentral()
}
app模塊的build.gradle
implementation 'io.github.toukomine:JpTextView:1.0.0'
基本使用
<komine.widgets.JpTextView
android:id="@+id/tv"
android:layout_
android:layout_height="wrap_content"
app:sourceText="天気はいいですね、散歩しましょう!"
app:sourceTextSize="20sp"
app:kanaTextSize="12sp"
app:oneMark="true"
app:bgColor="@color/black"
app:sourceTextColor="@color/white"
app:kanaTextColor="@color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
val tv = findViewById<JpTextView>(R.id.tv)
tv.setKanaList(arrayListOf(JpTextView.Kana("天気","てんき"),JpTextView.Kana("散歩","さんぽ")))
//tv.setKanaList(mapOf(Pair("天気","てんき"),Pair("散歩","さんぽ")))

標記模式
支持一次標記和總是標記,默認false,總是標記
app:oneMark="true" //開啟一次標記,所有文字只在第一次顯示假名注音

轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/543359.html
標籤:其他
