|
@@ -1,6 +1,7 @@
|
|
|
package com.guadou.cs_cptservices.binding
|
|
|
|
|
|
import android.graphics.Paint
|
|
|
+import android.graphics.Typeface
|
|
|
import android.graphics.drawable.Drawable
|
|
|
import android.os.Build
|
|
|
import android.text.Html
|
|
@@ -65,23 +66,33 @@ fun isCenterLine(textView: TextView, isUnderline: Boolean) {
|
|
|
/**
|
|
|
* 设置字体
|
|
|
*/
|
|
|
+@BindingAdapter("typefaceLight")
|
|
|
+fun typefaceLight(textView: TextView, boolean: Boolean) {
|
|
|
+ textView.typeface = Typeface.create("sans-serif-light", Typeface.NORMAL)
|
|
|
+}
|
|
|
+
|
|
|
+@BindingAdapter("typefaceRegular")
|
|
|
+fun typefaceRegular(textView: TextView, boolean: Boolean) {
|
|
|
+ textView.typeface = Typeface.create("sans-serif", Typeface.NORMAL)
|
|
|
+}
|
|
|
+
|
|
|
@BindingAdapter("typefaceMedium")
|
|
|
fun typefaceMedium(textView: TextView, boolean: Boolean) {
|
|
|
-// textView.typeface = TypefaceUtil.getSFMedium(textView.context)
|
|
|
+ textView.typeface = Typeface.create("sans-serif-medium", Typeface.NORMAL)
|
|
|
}
|
|
|
|
|
|
@BindingAdapter("typefaceBold")
|
|
|
fun typefaceSFBold(textView: TextView, boolean: Boolean) {
|
|
|
-// textView.typeface = TypefaceUtil.getSFBold(textView.context)
|
|
|
+ textView.typeface = Typeface.create("sans-serif", Typeface.BOLD)
|
|
|
}
|
|
|
|
|
|
@BindingAdapter("typefaceMediumOrBold")
|
|
|
fun typefaceMediumOrBold(textView: TextView, boolean: Boolean) {
|
|
|
-// if (boolean) { //true为粗体
|
|
|
-// textView.typeface = TypefaceUtil.getSFBold(textView.context)
|
|
|
-// } else {
|
|
|
-// textView.typeface = TypefaceUtil.getSFMedium(textView.context)
|
|
|
-// }
|
|
|
+ if (boolean) { //true为粗体
|
|
|
+ textView.typeface = Typeface.create("sans-serif", Typeface.BOLD)
|
|
|
+ } else {
|
|
|
+ textView.typeface = Typeface.create("sans-serif-medium", Typeface.NORMAL)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|