Преглед на файлове

0.0.48.beta27
- 修复 BottomDialog/BottomMenu 在暗色模式下 Cancel 按钮存在显示异常;
- 完善 iOS 主题下的模糊组件;

Kongzue преди 2 години
родител
ревизия
9f9a82cf93

+ 13 - 17
DialogX/src/main/java/com/kongzue/dialogx/dialogs/BottomDialog.java

@@ -447,6 +447,19 @@ public class BottomDialog extends BaseDialog implements DialogXBaseBottomDialog
                 @Override
                 public void run() {
                     getDialogXAnimImpl().doShowAnim(BottomDialog.this, bkg);
+
+                    int blurFrontColor = getResources().getColor(style.messageDialogBlurSettings().blurForwardColorRes(isLightTheme()));
+
+                    if (blurViews == null) {
+                        blurViews = findAllBlurView(dialogView);
+                    }
+
+                    if (blurViews != null) {
+                        for (View blurView : blurViews) {
+                            ((BlurViewType) blurView).setOverlayColor(blurFrontColor);
+                            ((BlurViewType) blurView).setRadiusPx(style.messageDialogBlurSettings().blurBackgroundRoundRadiusPx());
+                        }
+                    }
                 }
             });
 
@@ -460,18 +473,6 @@ public class BottomDialog extends BaseDialog implements DialogXBaseBottomDialog
             onDialogInit();
         }
 
-        private void findAllBlurView(View v) {
-            if (v instanceof BlurViewType) {
-                blurViews.add(v);
-            }
-            if (v instanceof ViewGroup) {
-                ViewGroup group = (ViewGroup) v;
-                for (int i = 0; i < group.getChildCount(); i++) {
-                    findAllBlurView(group.getChildAt(i));
-                }
-            }
-        }
-
         @Override
         public void refreshView() {
             if (boxRoot == null || getOwnActivity() == null) {
@@ -485,11 +486,6 @@ public class BottomDialog extends BaseDialog implements DialogXBaseBottomDialog
                 tintColor(btnSelectPositive, backgroundColor);
 
                 if (style.messageDialogBlurSettings() != null && style.messageDialogBlurSettings().blurBackground()) {
-                    if (blurViews == null) {
-                        blurViews = new ArrayList<>();
-                        findAllBlurView(dialogView);
-                    }
-
                     if (blurViews != null) {
                         for (View blurView : blurViews) {
                             ((BlurViewType) blurView).setOverlayColor(backgroundColor);

+ 24 - 10
DialogX/src/main/java/com/kongzue/dialogx/dialogs/MessageDialog.java

@@ -40,6 +40,7 @@ import com.kongzue.dialogx.DialogX;
 import com.kongzue.dialogx.R;
 import com.kongzue.dialogx.interfaces.BaseDialog;
 import com.kongzue.dialogx.interfaces.BaseOnDialogClickCallback;
+import com.kongzue.dialogx.interfaces.BlurViewType;
 import com.kongzue.dialogx.interfaces.DialogConvertViewInterface;
 import com.kongzue.dialogx.interfaces.DialogLifecycleCallback;
 import com.kongzue.dialogx.interfaces.DialogXAnimInterface;
@@ -58,6 +59,8 @@ import com.kongzue.dialogx.util.views.MaxRelativeLayout;
 import com.kongzue.dialogx.util.TextInfo;
 
 import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * @author: Kongzue
@@ -277,7 +280,8 @@ public class MessageDialog extends BaseDialog {
     }
 
     public class DialogImpl implements DialogConvertViewInterface {
-        BlurView blurView;
+
+        private List<View> blurViews;
 
         public DialogXBaseRelativeLayout boxRoot;
         public MaxRelativeLayout bkg;
@@ -351,14 +355,17 @@ public class MessageDialog extends BaseDialog {
                             @Override
                             public void run() {
                                 int blurFrontColor = getResources().getColor(style.messageDialogBlurSettings().blurForwardColorRes(isLightTheme()));
-                                blurView = new BlurView(getOwnActivity(), null);
-                                RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(bkg.getWidth(), bkg.getHeight());
-                                params.addRule(RelativeLayout.CENTER_IN_PARENT);
-                                blurView.setOverlayColor(backgroundColor == -1 ? blurFrontColor : backgroundColor);
-                                blurView.setOverrideOverlayColor(backgroundColor != -1);
-                                blurView.setTag("blurView");
-                                blurView.setRadiusPx(style.messageDialogBlurSettings().blurBackgroundRoundRadiusPx());
-                                bkg.addView(blurView, 0, params);
+
+                                if (blurViews == null) {
+                                    blurViews = findAllBlurView(dialogView);
+                                }
+
+                                if (blurViews != null) {
+                                    for (View blurView : blurViews) {
+                                        ((BlurViewType) blurView).setOverlayColor(blurFrontColor);
+                                        ((BlurViewType) blurView).setRadiusPx(style.messageDialogBlurSettings().blurBackgroundRoundRadiusPx());
+                                    }
+                                }
 
                                 setLifecycleState(Lifecycle.State.RESUMED);
                             }
@@ -553,8 +560,15 @@ public class MessageDialog extends BaseDialog {
                     tintColor(btnSelectNegative, backgroundColor);
                     tintColor(btnSelectPositive, backgroundColor);
                 }
-            }
 
+                if (style.messageDialogBlurSettings() != null && style.messageDialogBlurSettings().blurBackground()) {
+                   if (blurViews != null) {
+                        for (View blurView : blurViews) {
+                            ((BlurViewType) blurView).setOverlayColor(backgroundColor);
+                        }
+                    }
+                }
+            }
 
             bkg.setMaxWidth(getMaxWidth());
             bkg.setMaxHeight(getMaxHeight());

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

@@ -969,4 +969,18 @@ public abstract class BaseDialog implements LifecycleOwner {
             return null;
         return (FrameLayout) activity.getWindow().getDecorView();
     }
+
+    protected List<View> findAllBlurView(View v) {
+        List<View> result = new ArrayList<>();
+        if (v instanceof BlurViewType) {
+            result.add(v);
+        }
+        if (v instanceof ViewGroup) {
+            ViewGroup group = (ViewGroup) v;
+            for (int i = 0; i < group.getChildCount(); i++) {
+                result.addAll(findAllBlurView(group.getChildAt(i)));
+            }
+        }
+        return result;
+    }
 }

+ 1 - 0
DialogX/src/main/java/com/kongzue/dialogx/interfaces/BlurViewType.java

@@ -2,4 +2,5 @@ package com.kongzue.dialogx.interfaces;
 
 public interface BlurViewType {
     void setOverlayColor(int color);
+    void setRadiusPx(float r);
 }

+ 69 - 69
DialogX/src/main/java/com/kongzue/dialogx/util/views/BlurView.java

@@ -54,34 +54,34 @@ public class BlurView extends View {
     private View mDecorView;
     private boolean mDifferentRoot;
     private static int RENDERING_COUNT;
-    
+
     private Paint mPaint;
     private RectF mRectF;
-    
+
     public BlurView(Context context, AttributeSet attrs) {
         super(context, attrs);
         init(context, attrs);
     }
-    
+
     public BlurView(Context context) {
         super(context);
-        
+
         init(context, null);
     }
-    
+
     public BlurView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
         super(context, attrs, defStyleAttr);
-        
+
         init(context, attrs);
     }
-    
+
     private boolean isInit = false;
-    
+
     Paint cutPaint;
     Paint overlayPaint;
-    
+
     private void init(Context context, AttributeSet attrs) {
-        if (!isInit) {
+        if (!isInit && context != null) {
             TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RealtimeBlurView);
             mBlurRadius = a.getDimension(
                     R.styleable.RealtimeBlurView_realtimeBlurRadius,
@@ -89,24 +89,24 @@ public class BlurView extends View {
             );
             mDownsampleFactor = a.getFloat(R.styleable.RealtimeBlurView_realtimeDownsampleFactor, 4);
             mOverlayColor = a.getColor(R.styleable.RealtimeBlurView_realtimeOverlayColor, 0x00ffffff);
-            
+
             //ready rounded corner
             mPaint = new Paint();
             mPaint.setAntiAlias(true);
             mRectF = new RectF();
-            
+
             cutPaint = new Paint();
             cutPaint.setAntiAlias(true);
             cutPaint.setColor(mOverlayColor);
-            
+
             overlayPaint = new Paint();
             overlayPaint.setAntiAlias(true);
-            
+
             mRadius = a.getDimension(R.styleable.RealtimeBlurView_realtimeRadius, TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 15, context.getResources().getDisplayMetrics()));
             a.recycle();
-            
+
             isInit = true;
-            
+
             if (!isCompatMode()) {
                 setOutlineProvider(new ViewOutlineProvider() {
                     @Override
@@ -118,11 +118,11 @@ public class BlurView extends View {
             }
         }
     }
-    
+
     private boolean isCompatMode() {
         return Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP;
     }
-    
+
     public void setBlurRadius(float radius) {
         if (mBlurRadius != radius) {
             mBlurRadius = radius;
@@ -130,7 +130,7 @@ public class BlurView extends View {
             invalidate();
         }
     }
-    
+
     public void setRadiusPx(float r) {
         if (mRadius != r) {
             mRadius = r;
@@ -138,12 +138,12 @@ public class BlurView extends View {
             invalidate();
         }
     }
-    
+
     public void setDownsampleFactor(float factor) {
         if (factor <= 0) {
             throw new IllegalArgumentException("Downsample factor must be greater than 0.");
         }
-        
+
         if (mDownsampleFactor != factor) {
             mDownsampleFactor = factor;
             mDirty = true; // may also change blur radius
@@ -151,14 +151,14 @@ public class BlurView extends View {
             invalidate();
         }
     }
-    
+
     public void setOverlayColor(int color) {
         if (mOverlayColor != color) {
             mOverlayColor = color;
             invalidate();
         }
     }
-    
+
     private void releaseBitmap() {
         if (mBlurInput != null) {
             mBlurInput.destroy();
@@ -177,7 +177,7 @@ public class BlurView extends View {
             mBlurredBitmap = null;
         }
     }
-    
+
     private void releaseScript() {
         if (mRenderScript != null) {
             mRenderScript.destroy();
@@ -188,27 +188,27 @@ public class BlurView extends View {
             mBlurScript = null;
         }
     }
-    
+
     protected void release() {
         releaseBitmap();
         releaseScript();
     }
-    
+
     protected boolean prepare() {
         if (mBlurRadius == 0) {
             release();
             return false;
         }
-        
+
         float downsampleFactor = mDownsampleFactor;
-        
+
         if (mDirty || mRenderScript == null) {
             if (supportRenderScript && useBlur) {
                 if (mRenderScript == null) {
                     try {
                         mRenderScript = RenderScript.create(getContext());
                         mBlurScript = ScriptIntrinsicBlur.create(mRenderScript, Element.U8_4(mRenderScript));
-                        
+
                     } catch (Exception e) {
                         supportRenderScript = false;
                         if (isDebug()) {
@@ -216,7 +216,7 @@ public class BlurView extends View {
                         }
                     }
                 }
-                
+
                 mDirty = false;
                 float radius = mBlurRadius / downsampleFactor;
                 if (radius > 25) {
@@ -226,16 +226,16 @@ public class BlurView extends View {
                 if (mBlurScript != null) mBlurScript.setRadius(radius);
             }
         }
-        
+
         final int width = getWidth();
         final int height = getHeight();
-        
+
         int scaledWidth = Math.max(1, (int) (width / downsampleFactor));
         int scaledHeight = Math.max(1, (int) (height / downsampleFactor));
-        
+
         if (mBlurringCanvas == null || mBlurredBitmap == null || mBlurredBitmap.getWidth() != scaledWidth || mBlurredBitmap.getHeight() != scaledHeight) {
             releaseBitmap();
-            
+
             boolean r = false;
             try {
                 mBitmapToBlur = Bitmap.createBitmap(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888);
@@ -243,21 +243,21 @@ public class BlurView extends View {
                     return false;
                 }
                 mBlurringCanvas = new Canvas(mBitmapToBlur);
-                
+
                 if (!supportRenderScript || !useBlur) {
                     return true;
                 }
-                
+
                 mBlurInput = Allocation.createFromBitmap(mRenderScript, mBitmapToBlur,
                         Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT
                 );
                 mBlurOutput = Allocation.createTyped(mRenderScript, mBlurInput.getType());
-                
+
                 mBlurredBitmap = Bitmap.createBitmap(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888);
                 if (mBlurredBitmap == null) {
                     return false;
                 }
-                
+
                 r = true;
             } catch (Exception e) {
                 if (isDebug()) e.printStackTrace();
@@ -270,14 +270,14 @@ public class BlurView extends View {
         }
         return true;
     }
-    
+
     protected void blur(Bitmap bitmapToBlur, Bitmap blurredBitmap) {
         mBlurInput.copyFrom(bitmapToBlur);
         mBlurScript.setInput(mBlurInput);
         mBlurScript.forEach(mBlurOutput);
         mBlurOutput.copyTo(blurredBitmap);
     }
-    
+
     private final ViewTreeObserver.OnPreDrawListener preDrawListener = new ViewTreeObserver.OnPreDrawListener() {
         @Override
         public boolean onPreDraw() {
@@ -289,13 +289,13 @@ public class BlurView extends View {
                 decor.getLocationOnScreen(locations);
                 int x = -locations[0];
                 int y = -locations[1];
-                
+
                 getLocationOnScreen(locations);
                 x += locations[0];
                 y += locations[1];
 
                 mBitmapToBlur.eraseColor(mOverlayColor & 0xffffff);
-                
+
                 int rc = mBlurringCanvas.save();
                 mIsRendering = true;
                 RENDERING_COUNT++;
@@ -313,18 +313,18 @@ public class BlurView extends View {
                     RENDERING_COUNT--;
                     mBlurringCanvas.restoreToCount(rc);
                 }
-                
+
                 blur(mBitmapToBlur, mBlurredBitmap);
-                
+
                 if (redrawBitmap || mDifferentRoot) {
                     invalidate();
                 }
             }
-            
+
             return true;
         }
     };
-    
+
     @Override
     protected void onAttachedToWindow() {
         super.onAttachedToWindow();
@@ -351,7 +351,7 @@ public class BlurView extends View {
             mDifferentRoot = false;
         }
     }
-    
+
     @Override
     protected void onDetachedFromWindow() {
         if (mDecorView != null) {
@@ -360,13 +360,13 @@ public class BlurView extends View {
         release();
         super.onDetachedFromWindow();
     }
-    
+
     @Override
     public void draw(Canvas canvas) {
         if (!useBlur || !supportRenderScript) {
             mRectF.right = getWidth();
             mRectF.bottom = getHeight();
-            overlayPaint.setColor(needRemoveAlphaColor() ?  removeAlphaColor(mOverlayColor): mOverlayColor);
+            overlayPaint.setColor(needRemoveAlphaColor() ? removeAlphaColor(mOverlayColor) : mOverlayColor);
             canvas.drawRoundRect(mRectF, mRadius, mRadius, overlayPaint);
         } else {
             if (!mIsRendering && RENDERING_COUNT <= 0) {
@@ -374,7 +374,7 @@ public class BlurView extends View {
             }
         }
     }
-    
+
     @Override
     protected void onDraw(Canvas canvas) {
         super.onDraw(canvas);
@@ -384,7 +384,7 @@ public class BlurView extends View {
             drawBlurredBitmap(canvas, mBlurredBitmap);
         }
     }
-    
+
     private void drawBlurredBitmapCompat(Canvas canvas) {
         if (mBlurredBitmap != null) {
             mRectDst.right = getWidth();
@@ -403,7 +403,7 @@ public class BlurView extends View {
             if (overlyBitmap != null) canvas.drawBitmap(overlyBitmap, 0, 0, null);
         }
     }
-    
+
     protected void drawBlurredBitmap(Canvas canvas, Bitmap blurredBitmap) {
         if (blurredBitmap != null) {
             mRectSrc.right = blurredBitmap.getWidth();
@@ -411,13 +411,13 @@ public class BlurView extends View {
             mRectDst.right = getWidth();
             mRectDst.bottom = getHeight();
             canvas.drawBitmap(blurredBitmap, mRectSrc, mRectDst, null);
-            canvas.drawColor(needRemoveAlphaColor() ?  removeAlphaColor(mOverlayColor): mOverlayColor);
+            canvas.drawColor(needRemoveAlphaColor() ? removeAlphaColor(mOverlayColor) : mOverlayColor);
         } else {
             Bitmap overlyBitmap = drawOverlyColor(Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888));
             if (overlyBitmap != null) canvas.drawBitmap(overlyBitmap, 0, 0, null);
         }
     }
-    
+
     private Bitmap getRoundedCornerBitmap(Bitmap bitmap, Rect mRectDst) {
         bitmap = drawOverlyColor(resizeImage(bitmap, mRectDst.width(), mRectDst.height()));
         if (bitmap == null) return null;
@@ -430,7 +430,7 @@ public class BlurView extends View {
         canvas.drawRoundRect(new RectF(mRectDst), mRadius, mRadius, paint);
         return output;
     }
-    
+
     private Bitmap drawOverlyColor(Bitmap bitmap) {
         if (bitmap != null) {
             Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
@@ -438,13 +438,13 @@ public class BlurView extends View {
             Rect originRect = new Rect();
             originRect.set(0, 0, bitmap.getWidth(), bitmap.getHeight());
             canvas.drawBitmap(bitmap, originRect, originRect, overlayPaint);
-            canvas.drawColor(needRemoveAlphaColor() ?  removeAlphaColor(mOverlayColor): mOverlayColor);
+            canvas.drawColor(needRemoveAlphaColor() ? removeAlphaColor(mOverlayColor) : mOverlayColor);
             return output;
         } else {
             return null;
         }
     }
-    
+
     private Bitmap resizeImage(Bitmap bitmap, int newWidth, int newHeight) {
         if (bitmap != null) {
             int width = bitmap.getWidth();
@@ -458,24 +458,24 @@ public class BlurView extends View {
             return null;
         }
     }
-    
+
     private static boolean supportRenderScript = false;
     private boolean useBlur = true;
-    
+
     public boolean isUseBlur() {
         return useBlur;
     }
-    
+
     public BlurView setUseBlur(boolean useBlur) {
         this.useBlur = useBlur;
         invalidate();
         return this;
     }
 
-    private boolean needRemoveAlphaColor(){
-        if (overrideOverlayColor){
+    private boolean needRemoveAlphaColor() {
+        if (overrideOverlayColor) {
             return false;
-        }else{
+        } else {
             return !(supportRenderScript && useBlur);
         }
     }
@@ -494,7 +494,7 @@ public class BlurView extends View {
         int blue = Color.blue(color);
         return Color.argb(alpha, red, green, blue);
     }
-    
+
     static {
         /**
          * 之所以需要启动一个新线程检测RenderScript是否可用的原因是不清楚Android什么时候对loadClass做了变更,
@@ -516,23 +516,23 @@ public class BlurView extends View {
             }
         }.start();
     }
-    
+
     public static boolean DEBUGMODE = false;
-    
+
     static boolean isDebug() {
         return DEBUGMODE && DialogX.DEBUGMODE;
     }
-    
+
     private static void log(Object o) {
         if (isDebug()) Log.i(">>>", "DialogX.BlurView: " + o.toString());
     }
-    
+
     public static void error(Object o) {
         if (isDebug()) Log.e(">>>", o.toString());
     }
 
     public BlurView setOverrideOverlayColor(boolean overrideOverlayColor) {
-        log("setOverrideOverlayColor: "+overrideOverlayColor);
+        log("setOverrideOverlayColor: " + overrideOverlayColor);
         this.overrideOverlayColor = overrideOverlayColor;
         return this;
     }

+ 2 - 0
DialogX/src/main/res/layout/layout_dialogx_bottom_material_dark.xml

@@ -100,6 +100,7 @@
                     android:paddingRight="10dp">
 
                     <TextView
+                        android:id="@+id/btn_selectOther"
                         android:layout_width="wrap_content"
                         android:layout_height="36dp"
                         android:layout_marginTop="10dp"
@@ -121,6 +122,7 @@
                         android:layout_weight="1" />
 
                     <TextView
+                        android:id="@+id/btn_selectNegative"
                         android:layout_width="wrap_content"
                         android:layout_height="36dp"
                         android:layout_marginTop="10dp"

+ 1 - 0
DialogX/src/main/res/values/attrs.xml

@@ -16,6 +16,7 @@
         <attr name="realtimeOverlayColor" format="color"/>
         <attr name="realtimeRadius" format="dimension"/>
         <attr name="dialogxDarkMode" format="boolean"/>
+        <attr name="dialogxOverlayColorNoAlpha" format="boolean"/>
     </declare-styleable>
 
     <declare-styleable name="ProgressView">

+ 26 - 21
DialogXIOSStyle/src/main/java/com/kongzue/dialogx/style/views/BlurLinearLayout.java

@@ -36,6 +36,7 @@ public class BlurLinearLayout extends LinearLayout implements BlurViewType {
     private float mDownSampleFactor = 4;
     private int mOverlayColor = Color.WHITE;
     private float mBlurRadius = 35;
+    private boolean noAlpha = false;
     private boolean overrideOverlayColor = false;
 
     private float mRadius = 0;
@@ -77,32 +78,23 @@ public class BlurLinearLayout extends LinearLayout implements BlurViewType {
     Paint overlayPaint;
 
     private void init(Context context, AttributeSet attrs) {
-        if (!isInit) {
+        if (!isInit && context != null) {
             TypedArray a = context.obtainStyledAttributes(attrs, com.kongzue.dialogx.R.styleable.RealtimeBlurView);
             darkMode = a.getBoolean(com.kongzue.dialogx.R.styleable.RealtimeBlurView_dialogxDarkMode, false);
-            mBlurRadius = a.getDimension(com.kongzue.dialogx.R.styleable.RealtimeBlurView_realtimeBlurRadius, dip2px(35));
+            mBlurRadius = a.getDimension(com.kongzue.dialogx.R.styleable.RealtimeBlurView_realtimeBlurRadius, dip2px(context, 35));
             mDownSampleFactor = a.getFloat(com.kongzue.dialogx.R.styleable.RealtimeBlurView_realtimeDownsampleFactor, 4);
             mOverlayColor = a.getColor(com.kongzue.dialogx.R.styleable.RealtimeBlurView_realtimeOverlayColor, getResources().getColor(darkMode ? R.color.dialogxIOSBkgDark : R.color.dialogxIOSBkgLight));
-            mRadius = a.getDimension(com.kongzue.dialogx.R.styleable.RealtimeBlurView_realtimeRadius, dip2px(15));
+            mRadius = a.getDimension(com.kongzue.dialogx.R.styleable.RealtimeBlurView_realtimeRadius, dip2px(context, 15));
+            noAlpha = a.getBoolean(com.kongzue.dialogx.R.styleable.RealtimeBlurView_dialogxOverlayColorNoAlpha, false);
             a.recycle();
 
-            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
-                setOutlineProvider(new ViewOutlineProvider() {
-                    @Override
-                    public void getOutline(View view, Outline outline) {
-                        outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), mRadius);
-                    }
-                });
-                setClipToOutline(true);
-            }
-
             mPaint = new Paint();
             mPaint.setAntiAlias(true);
             mRectF = new RectF();
 
             cutPaint = new Paint();
             cutPaint.setAntiAlias(true);
-            cutPaint.setColor(mOverlayColor);
+            cutPaint.setColor(getOverlayColor());
 
             overlayPaint = new Paint();
             overlayPaint.setAntiAlias(true);
@@ -137,6 +129,15 @@ public class BlurLinearLayout extends LinearLayout implements BlurViewType {
             mRadius = r;
             mDirty = true;
             invalidate();
+            if (!isCompatMode()) {
+                setOutlineProvider(new ViewOutlineProvider() {
+                    @Override
+                    public void getOutline(View view, Outline outline) {
+                        outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), mRadius);
+                    }
+                });
+                setClipToOutline(true);
+            }
         }
     }
 
@@ -296,7 +297,7 @@ public class BlurLinearLayout extends LinearLayout implements BlurViewType {
                 y += locations[1];
 
                 // just erase transparent
-                mBitmapToBlur.eraseColor(mOverlayColor & 0xffffff);
+                mBitmapToBlur.eraseColor(getOverlayColor() & 0xffffff);
 
                 int rc = mBlurringCanvas.save();
                 mIsRendering = true;
@@ -378,7 +379,7 @@ public class BlurLinearLayout extends LinearLayout implements BlurViewType {
         if (!useBlur || !supportRenderScript) {
             mRectF.right = getWidth();
             mRectF.bottom = getHeight();
-            overlayPaint.setColor(needRemoveAlphaColor() ? removeAlphaColor(mOverlayColor) : mOverlayColor);
+            overlayPaint.setColor(getOverlayColor());
             canvas.drawRoundRect(mRectF, mRadius, mRadius, overlayPaint);
         } else {
             if (!mIsRendering && RENDERING_COUNT <= 0) {
@@ -424,7 +425,7 @@ public class BlurLinearLayout extends LinearLayout implements BlurViewType {
             mRectDst.right = getWidth();
             mRectDst.bottom = getHeight();
             canvas.drawBitmap(blurredBitmap, mRectSrc, mRectDst, null);
-            canvas.drawColor(mOverlayColor);
+            canvas.drawColor(getOverlayColor());
         } else {
             Bitmap overlyBitmap = drawOverlyColor(Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888));
             if (overlyBitmap != null) canvas.drawBitmap(overlyBitmap, 0, 0, null);
@@ -451,7 +452,7 @@ public class BlurLinearLayout extends LinearLayout implements BlurViewType {
             Rect originRect = new Rect();
             originRect.set(0, 0, bitmap.getWidth(), bitmap.getHeight());
             canvas.drawBitmap(bitmap, originRect, originRect, overlayPaint);
-            canvas.drawColor(needRemoveAlphaColor() ? removeAlphaColor(mOverlayColor) : mOverlayColor);
+            canvas.drawColor(getOverlayColor());
             return output;
         } else {
             return null;
@@ -489,7 +490,7 @@ public class BlurLinearLayout extends LinearLayout implements BlurViewType {
         if (overrideOverlayColor) {
             return false;
         } else {
-            return !(supportRenderScript && useBlur);
+            return noAlpha || !(supportRenderScript && useBlur);
         }
     }
 
@@ -550,8 +551,12 @@ public class BlurLinearLayout extends LinearLayout implements BlurViewType {
         return this;
     }
 
-    private int dip2px(float dpValue) {
-        final float scale = getResources().getDisplayMetrics().density;
+    private int dip2px(Context context, float dpValue) {
+        final float scale = context.getResources().getDisplayMetrics().density;
         return (int) (dpValue * scale + 0.5f);
     }
+
+    private int getOverlayColor(){
+        return needRemoveAlphaColor() ? removeAlphaColor(mOverlayColor) : mOverlayColor;
+    }
 }

+ 27 - 21
DialogXIOSStyle/src/main/java/com/kongzue/dialogx/style/views/BlurRelativeLayout.java

@@ -36,6 +36,7 @@ public class BlurRelativeLayout extends RelativeLayout implements BlurViewType {
     private float mDownSampleFactor = 4;
     private int mOverlayColor = Color.WHITE;
     private float mBlurRadius = 35;
+    private boolean noAlpha = false;
     private boolean overrideOverlayColor = false;
 
     private float mRadius = 0;
@@ -77,32 +78,23 @@ public class BlurRelativeLayout extends RelativeLayout implements BlurViewType {
     Paint overlayPaint;
 
     private void init(Context context, AttributeSet attrs) {
-        if (!isInit) {
+        if (!isInit && context != null) {
             TypedArray a = context.obtainStyledAttributes(attrs, com.kongzue.dialogx.R.styleable.RealtimeBlurView);
             darkMode = a.getBoolean(com.kongzue.dialogx.R.styleable.RealtimeBlurView_dialogxDarkMode, false);
-            mBlurRadius = a.getDimension(com.kongzue.dialogx.R.styleable.RealtimeBlurView_realtimeBlurRadius, dip2px(35));
+            mBlurRadius = a.getDimension(com.kongzue.dialogx.R.styleable.RealtimeBlurView_realtimeBlurRadius, dip2px(context, 35));
             mDownSampleFactor = a.getFloat(com.kongzue.dialogx.R.styleable.RealtimeBlurView_realtimeDownsampleFactor, 4);
             mOverlayColor = a.getColor(com.kongzue.dialogx.R.styleable.RealtimeBlurView_realtimeOverlayColor, getResources().getColor(darkMode ? R.color.dialogxIOSBkgDark : R.color.dialogxIOSBkgLight));
-            mRadius = a.getDimension(com.kongzue.dialogx.R.styleable.RealtimeBlurView_realtimeRadius, dip2px(15));
+            mRadius = a.getDimension(com.kongzue.dialogx.R.styleable.RealtimeBlurView_realtimeRadius, dip2px(context, 15));
+            noAlpha = a.getBoolean(com.kongzue.dialogx.R.styleable.RealtimeBlurView_dialogxOverlayColorNoAlpha, false);
             a.recycle();
 
-            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
-                setOutlineProvider(new ViewOutlineProvider() {
-                    @Override
-                    public void getOutline(View view, Outline outline) {
-                        outline.setRoundRect(0, 0, view.getWidth(),view.getHeight(), mRadius);
-                    }
-                });
-                setClipToOutline(true);
-            }
-
             mPaint = new Paint();
             mPaint.setAntiAlias(true);
             mRectF = new RectF();
 
             cutPaint = new Paint();
             cutPaint.setAntiAlias(true);
-            cutPaint.setColor(mOverlayColor);
+            cutPaint.setColor(getOverlayColor());
 
             overlayPaint = new Paint();
             overlayPaint.setAntiAlias(true);
@@ -129,6 +121,15 @@ public class BlurRelativeLayout extends RelativeLayout implements BlurViewType {
             mBlurRadius = radius;
             mDirty = true;
             invalidate();
+            if (!isCompatMode()) {
+                setOutlineProvider(new ViewOutlineProvider() {
+                    @Override
+                    public void getOutline(View view, Outline outline) {
+                        outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), mRadius);
+                    }
+                });
+                setClipToOutline(true);
+            }
         }
     }
 
@@ -296,7 +297,7 @@ public class BlurRelativeLayout extends RelativeLayout implements BlurViewType {
                 y += locations[1];
 
                 // just erase transparent
-                mBitmapToBlur.eraseColor(mOverlayColor & 0xffffff);
+                mBitmapToBlur.eraseColor(getOverlayColor() & 0xffffff);
 
                 int rc = mBlurringCanvas.save();
                 mIsRendering = true;
@@ -378,7 +379,7 @@ public class BlurRelativeLayout extends RelativeLayout implements BlurViewType {
         if (!useBlur || !supportRenderScript) {
             mRectF.right = getWidth();
             mRectF.bottom = getHeight();
-            overlayPaint.setColor(needRemoveAlphaColor() ? removeAlphaColor(mOverlayColor) : mOverlayColor);
+            overlayPaint.setColor(getOverlayColor());
             canvas.drawRoundRect(mRectF, mRadius, mRadius, overlayPaint);
         } else {
             if (!mIsRendering && RENDERING_COUNT <= 0) {
@@ -424,7 +425,7 @@ public class BlurRelativeLayout extends RelativeLayout implements BlurViewType {
             mRectDst.right = getWidth();
             mRectDst.bottom = getHeight();
             canvas.drawBitmap(blurredBitmap, mRectSrc, mRectDst, null);
-            canvas.drawColor(mOverlayColor);
+            canvas.drawColor(getOverlayColor());
         } else {
             Bitmap overlyBitmap = drawOverlyColor(Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888));
             if (overlyBitmap != null) canvas.drawBitmap(overlyBitmap, 0, 0, null);
@@ -451,7 +452,7 @@ public class BlurRelativeLayout extends RelativeLayout implements BlurViewType {
             Rect originRect = new Rect();
             originRect.set(0, 0, bitmap.getWidth(), bitmap.getHeight());
             canvas.drawBitmap(bitmap, originRect, originRect, overlayPaint);
-            canvas.drawColor(needRemoveAlphaColor() ? removeAlphaColor(mOverlayColor) : mOverlayColor);
+            canvas.drawColor(getOverlayColor());
             return output;
         } else {
             return null;
@@ -489,7 +490,7 @@ public class BlurRelativeLayout extends RelativeLayout implements BlurViewType {
         if (overrideOverlayColor) {
             return false;
         } else {
-            return !(supportRenderScript && useBlur);
+            return noAlpha || !(supportRenderScript && useBlur);
         }
     }
 
@@ -549,8 +550,13 @@ public class BlurRelativeLayout extends RelativeLayout implements BlurViewType {
         this.overrideOverlayColor = overrideOverlayColor;
         return this;
     }
-    private int dip2px(float dpValue) {
-        final float scale = getResources().getDisplayMetrics().density;
+
+    private int dip2px(Context context, float dpValue) {
+        final float scale = context.getResources().getDisplayMetrics().density;
         return (int) (dpValue * scale + 0.5f);
     }
+
+    private int getOverlayColor(){
+        return needRemoveAlphaColor() ? removeAlphaColor(mOverlayColor) : mOverlayColor;
+    }
 }

+ 2 - 1
DialogXIOSStyle/src/main/res/layout/layout_dialogx_bottom_ios.xml

@@ -115,7 +115,8 @@
                     android:layout_marginBottom="10dp"
                     android:divider="@color/dialogxIOSSplitLight"
                     android:orientation="vertical"
-                    android:showDividers="middle">
+                    android:showDividers="middle"
+                    app:dialogxOverlayColorNoAlpha="true">
 
                     <TextView
                         android:id="@+id/btn_selectPositive"

+ 1 - 0
DialogXIOSStyle/src/main/res/layout/layout_dialogx_bottom_ios_dark.xml

@@ -117,6 +117,7 @@
                     android:divider="@drawable/rect_dialogx_ios_menu_split_divider"
                     android:orientation="vertical"
                     android:showDividers="middle"
+                    app:dialogxOverlayColorNoAlpha="true"
                     app:dialogxDarkMode="true">
 
                     <TextView

+ 2 - 2
DialogXIOSStyle/src/main/res/layout/layout_dialogx_ios.xml

@@ -20,7 +20,7 @@
             android:layout_marginRight="35dp"
             app:maxLayoutWidth="270dp">
 
-            <LinearLayout
+            <com.kongzue.dialogx.style.views.BlurLinearLayout
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:clickable="true"
@@ -164,7 +164,7 @@
 
                 </LinearLayout>
 
-            </LinearLayout>
+            </com.kongzue.dialogx.style.views.BlurLinearLayout>
 
         </com.kongzue.dialogx.util.views.MaxRelativeLayout>
 

+ 3 - 2
DialogXIOSStyle/src/main/res/layout/layout_dialogx_ios_dark.xml

@@ -20,9 +20,10 @@
             android:layout_marginRight="35dp"
             app:maxLayoutWidth="270dp">
 
-            <LinearLayout
+            <com.kongzue.dialogx.style.views.BlurLinearLayout
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
+                app:dialogxDarkMode="true"
                 android:clickable="true"
                 android:orientation="vertical">
 
@@ -164,7 +165,7 @@
 
                 </LinearLayout>
 
-            </LinearLayout>
+            </com.kongzue.dialogx.style.views.BlurLinearLayout>
 
         </com.kongzue.dialogx.util.views.MaxRelativeLayout>
 

+ 25 - 0
app/src/main/res/layout/layout_test1.xml

@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <EditText
+        android:id="@+id/edit_userName"
+        android:layout_width="match_parent"
+        android:layout_height="50dp"
+        android:layout_marginHorizontal="15dp"
+        android:layout_marginTop="10dp"
+        android:background="@drawable/ios_edit_box_bkg"
+        android:gravity="center"
+        android:hint="请输入账号"
+        android:inputType="textEmailAddress" />
+
+    <com.kongzue.dialogxdemo.custom.recycleview.CustomRecycleView
+        android:id="@+id/recycleView"
+        android:tag="ScrollController"
+        android:orientation="vertical"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"/>
+
+</LinearLayout>

+ 1 - 1
gradle.properties

@@ -19,6 +19,6 @@ android.useAndroidX=true
 # Automatically convert third-party libraries to use AndroidX
 android.enableJetifier=true
 
-BUILD_VERSION=0.0.48.beta26
+BUILD_VERSION=0.0.48.beta27
 BUILD_VERSION_INT=47
 DIALOGX_STYLE_VERSION=5