Selaa lähdekoodia

0.0.50.beta24 pre
- 修复PopMenu在未绑定baseView而指定setAlignGravity会出现的空指针异常;
- 修复DialogListBuilder可能存在的空指针风险;
- PopMenu 增加 setBackgroundColor 和 setBackgroundColorRes 方法;

Kongzue 4 kuukautta sitten
vanhempi
commit
a29d2e9d3e
1 muutettua tiedostoa jossa 21 lisäystä ja 0 poistoa
  1. 21 0
      DialogX/src/main/java/com/kongzue/dialogx/dialogs/PopMenu.java

+ 21 - 0
DialogX/src/main/java/com/kongzue/dialogx/dialogs/PopMenu.java

@@ -21,6 +21,8 @@ import android.widget.AdapterView;
 import android.widget.RelativeLayout;
 import android.widget.TextView;
 
+import androidx.annotation.ColorInt;
+import androidx.annotation.ColorRes;
 import androidx.annotation.Nullable;
 import androidx.lifecycle.Lifecycle;
 
@@ -616,6 +618,9 @@ public class PopMenu extends BaseDialog {
             } else {
                 boxRoot.setClickable(false);
             }
+            if (backgroundColor != null) {
+                tintColor(boxBody, backgroundColor);
+            }
 
             if (backgroundRadius > -1) {
                 if (boxBody.getBackground() instanceof GradientDrawable) {
@@ -1508,4 +1513,20 @@ public class PopMenu extends BaseDialog {
         }
         return enabled;
     }
+
+    public int getBackgroundColor() {
+        return backgroundColor;
+    }
+
+    public PopMenu setBackgroundColor(@ColorInt int backgroundColor) {
+        this.backgroundColor = backgroundColor;
+        refreshUI();
+        return this;
+    }
+
+    public PopMenu setBackgroundColorRes(@ColorRes int backgroundColorResId) {
+        this.backgroundColor = getColor(backgroundColorResId);
+        refreshUI();
+        return this;
+    }
 }