Ver Fonte

0.0.50.beta17
- TextInfo 新增对自定义 Typeface 的支持;
- 修复了 MessageDialog 和 BottomDialog 在不设置任何 button 时可能存在布局占位的问题;
- 修复了 MIUI 主题中的已知问题;
- 去除了 OnBindView 的异常日志打印;

Kongzue há 8 meses atrás
pai
commit
c9255f08c7

+ 3 - 0
DialogX/src/main/java/com/kongzue/dialogx/interfaces/BaseDialog.java

@@ -577,6 +577,9 @@ public abstract class BaseDialog implements LifecycleOwner {
         } else {
             textView.setMaxLines(Integer.MAX_VALUE);
         }
+        if (textInfo.getTypeface() != null) {
+            textView.setTypeface(textInfo.getTypeface());
+        }
 
         textView.getPaint().setFakeBoldText(textInfo.isBold());
     }

+ 13 - 1
DialogX/src/main/java/com/kongzue/dialogx/util/TextInfo.java

@@ -1,5 +1,6 @@
 package com.kongzue.dialogx.util;
 
+import android.graphics.Typeface;
 import android.util.TypedValue;
 
 import androidx.annotation.ColorInt;
@@ -20,6 +21,7 @@ public class TextInfo {
     private boolean bold = false;           //是否粗体
     private int maxLines = -1;              //最大行数
     private boolean showEllipsis = false;   //显示省略号
+    private Typeface typeface;              //指定字体样式
     
     public enum FONT_SIZE_UNIT {
         DP,
@@ -103,7 +105,16 @@ public class TextInfo {
         this.fontSizeUnit = fontSizeUnit;
         return this;
     }
-    
+
+    public Typeface getTypeface() {
+        return typeface;
+    }
+
+    public TextInfo setTypeface(Typeface typeface) {
+        this.typeface = typeface;
+        return this;
+    }
+
     @Override
     public String toString() {
         return "TextInfo{" +
@@ -113,6 +124,7 @@ public class TextInfo {
                 ", bold=" + bold +
                 ", maxLines=" + maxLines +
                 ", showEllipsis=" + showEllipsis +
+                ", typeface=" + typeface +
                 '}';
     }
 }