瀏覽代碼

Since Roboto Medium is only available on API 21 and above, Roboto Bold is used below API 21 in place of the medium font (for action buttons and other elements). Resolves https://github.com/afollestad/material-dialogs/issues/537.

Aidan Follestad 10 年之前
父節點
當前提交
5ee80393ac
共有 1 個文件被更改,包括 4 次插入3 次删除
  1. 4 3
      library/src/main/java/com/afollestad/materialdialogs/MaterialDialog.java

+ 4 - 3
library/src/main/java/com/afollestad/materialdialogs/MaterialDialog.java

@@ -470,7 +470,10 @@ public class MaterialDialog extends DialogBase implements
 
             if (this.mediumFont == null) {
                 try {
-                    this.mediumFont = Typeface.create("sans-serif-medium", Typeface.NORMAL);
+                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
+                        this.mediumFont = Typeface.create("sans-serif-medium", Typeface.NORMAL);
+                    else
+                        this.mediumFont = Typeface.create("sans-serif", Typeface.BOLD);
                 } catch (Throwable ignored) {
                 }
             }
@@ -480,8 +483,6 @@ public class MaterialDialog extends DialogBase implements
                 } catch (Throwable ignored) {
                 }
             }
-            if (this.mediumFont == null)
-                this.mediumFont = this.regularFont;
         }
 
         private void checkSingleton() {