소스 검색

Added a method to change content Color.

Added a contentColor method (similar to titleColor) that (obviously) changes the color of the builder.content TextView.
Phascinate 10 년 전
부모
커밋
4d5bfdf117
1개의 변경된 파일18개의 추가작업 그리고 1개의 파일을 삭제
  1. 18 1
      library/src/main/java/com/afollestad/materialdialogs/MaterialDialog.java

+ 18 - 1
library/src/main/java/com/afollestad/materialdialogs/MaterialDialog.java

@@ -134,7 +134,6 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
         content.setText(builder.content);
         content.setMovementMethod(new LinkMovementMethod());
         setTypeface(content, regularFont);
-        content.setTextColor(DialogUtils.resolveColor(getContext(), android.R.attr.textColorSecondary));
         content.setLineSpacing(0f, builder.contentLineSpacingMultiplier);
         if (this.positiveColor == 0) {
             content.setLinkTextColor(DialogUtils.resolveColor(getContext(), android.R.attr.textColorPrimary));
@@ -216,6 +215,13 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
                 title.setGravity(Gravity.RIGHT);
             }
         }
+        
+        //Content color is set here.
+        if (builder.contentColor != -1) {
+                content.setTextColor(builder.contentColor);
+            } else {
+                content.setTextColor(DialogUtils.resolveColor(getContext(), android.R.attr.textColorPrimary));
+            }
 
         invalidateActions();
         setOnShowListenerInternal();
@@ -598,6 +604,7 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
         protected Alignment titleAlignment = Alignment.LEFT;
         protected Alignment contentAlignment = Alignment.LEFT;
         protected int titleColor = -1;
+        protected int contentColor = -1;
         protected CharSequence content;
         protected CharSequence[] items;
         protected CharSequence positiveText;
@@ -707,6 +714,16 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
             return this;
         }
 
+        public Builder contentColor(int color) {
+            this.contentColor = color;
+            return this;
+        }
+
+        public Builder contentColorRes(@ColorRes int colorRes) {
+            contentColor(this.context.getResources().getColor(colorRes));
+            return this;
+        }
+
         public Builder content(@StringRes int contentRes) {
             content(this.context.getString(contentRes));
             return this;