public static void immersiveStatusBar(Window window, @FloatRange(from = 0.0d, to = 1.0d) float alpha) { if (VERSION.SDK_INT >= 19) { if (VERSION.SDK_INT >= 21) { window.clearFlags(67108864); window.addFlags(Integer.MIN_VALUE); window.setStatusBarColor(0); window.getDecorView().setSystemUiVisibility((window.getDecorView() .getSystemUiVisibility() | 1024) | 256); } else { window.addFlags(67108864); } ViewGroup decorView = (ViewGroup) window.getDecorView(); View rootView = ((ViewGroup) window.getDecorView().findViewById(16908290)).getChildAt (0); int statusBarHeight = getStatusBarHeight(window.getContext()); if (rootView != null) { LayoutParams lp = (LayoutParams) rootView.getLayoutParams(); ViewCompat.setFitsSystemWindows(rootView, true); lp.topMargin = -statusBarHeight; rootView.setLayoutParams(lp); } setTranslucentView(decorView, alpha); } }
/** * Converts a color from CIE Lab to CIE XYZ representation. * * <p>The resulting XYZ representation will use the D65 illuminant and the CIE * 2° Standard Observer (1931).</p> * * <ul> * <li>outXyz[0] is X [0 ...95.047)</li> * <li>outXyz[1] is Y [0...100)</li> * <li>outXyz[2] is Z [0...108.883)</li> * </ul> * * @param l L component value [0...100) * @param a A component value [-128...127) * @param b B component value [-128...127) * @param outXyz 3-element array which holds the resulting XYZ components */ public static void LABToXYZ(@FloatRange(from = 0f, to = 100) final double l, @FloatRange(from = -128, to = 127) final double a, @FloatRange(from = -128, to = 127) final double b, @NonNull double[] outXyz) { final double fy = (l + 16) / 116; final double fx = a / 500 + fy; final double fz = fy - b / 200; double tmp = Math.pow(fx, 3); final double xr = tmp > XYZ_EPSILON ? tmp : (116 * fx - 16) / XYZ_KAPPA; final double yr = l > XYZ_KAPPA * XYZ_EPSILON ? Math.pow(fy, 3) : l / XYZ_KAPPA; tmp = Math.pow(fz, 3); final double zr = tmp > XYZ_EPSILON ? tmp : (116 * fz - 16) / XYZ_KAPPA; outXyz[0] = xr * XYZ_WHITE_REFERENCE_X; outXyz[1] = yr * XYZ_WHITE_REFERENCE_Y; outXyz[2] = zr * XYZ_WHITE_REFERENCE_Z; }
/** * Calculate a variant of the color to make it more suitable for overlaying information. Light * colors will be lightened and dark colors will be darkened * * @param color the color to adjust * @param isDark whether {@code color} is light or dark * @param lightnessMultiplier the amount to modify the color e.g. 0.1f will alter it by 10% * @return the adjusted color */ public static @ColorInt int scrimify(@ColorInt int color, boolean isDark, @FloatRange(from = 0f, to = 1f) float lightnessMultiplier) { float[] hsl = new float[3]; android.support.v4.graphics.ColorUtils.colorToHSL(color, hsl); if (!isDark) { lightnessMultiplier += 1f; } else { lightnessMultiplier = 1f - lightnessMultiplier; } hsl[2] = constrain(0f, 1f, hsl[2] * lightnessMultiplier); return android.support.v4.graphics.ColorUtils.HSLToColor(hsl); }
/** * 创建一张渐变图片,支持圆角 * * @param startColor 渐变开始色 * @param endColor 渐变结束色 * @param radius 圆角大小 * @param centerX 渐变中心点 X 轴坐标 * @param centerY 渐变中心点 Y 轴坐标 * @return */ @TargetApi(16) public static GradientDrawable createCircleGradientDrawable(@ColorInt int startColor, @ColorInt int endColor, int radius, @FloatRange(from = 0f, to = 1f) float centerX, @FloatRange(from = 0f, to = 1f) float centerY) { GradientDrawable gradientDrawable = new GradientDrawable(); gradientDrawable.setColors(new int[]{ startColor, endColor }); gradientDrawable.setGradientType(GradientDrawable.RADIAL_GRADIENT); gradientDrawable.setGradientRadius(radius); gradientDrawable.setGradientCenter(centerX, centerY); return gradientDrawable; }
/** * Android4.4以上的状态栏着色 * * @param window 一般都是用于Activity的window,也可以是其他的例如Dialog,DialogFragment * @param statusBarColor 状态栏颜色 * @param alpha 透明栏透明度[0.0-1.0] */ public static void tintStatusBar(Window window, @ColorInt int statusBarColor, @FloatRange(from = 0.0, to = 1.0) float alpha) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { return; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(Color.TRANSPARENT); } else { window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } ViewGroup decorView = (ViewGroup) window.getDecorView(); ViewGroup contentView = (ViewGroup) window.getDecorView() .findViewById(Window.ID_ANDROID_CONTENT); View rootView = contentView.getChildAt(0); if (rootView != null) { ViewCompat.setFitsSystemWindows(rootView, true); } setStatusBar(decorView, statusBarColor, true); setTranslucentView(decorView, alpha); }
/** * Android4.4以上的状态栏着色(针对于DrawerLayout) * 注: * 1.如果出现界面展示不正确,删除布局中所有fitsSystemWindows属性,尤其是DrawerLayout的fitsSystemWindows属性 * 2.可以版本判断在5.0以上不调用该方法,使用系统自带 * * @param activity Activity对象 * @param drawerLayout DrawerLayout对象 * @param statusBarColor 状态栏颜色 * @param alpha 透明栏透明度[0.0-1.0] */ public static void tintStatusBarForDrawer(Activity activity, DrawerLayout drawerLayout, @ColorInt int statusBarColor, @FloatRange(from = 0.0, to = 1.0) float alpha) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { return; } Window window = activity.getWindow(); ViewGroup decorView = (ViewGroup) window.getDecorView(); ViewGroup drawContent = (ViewGroup) drawerLayout.getChildAt(0); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(Color.TRANSPARENT); drawerLayout.setStatusBarBackgroundColor(statusBarColor); int systemUiVisibility = window.getDecorView().getSystemUiVisibility(); systemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; systemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE; window.getDecorView().setSystemUiVisibility(systemUiVisibility); } else { window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } setStatusBar(decorView, statusBarColor, true, true); setTranslucentView(decorView, alpha); drawerLayout.setFitsSystemWindows(false); drawContent.setFitsSystemWindows(true); ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1); drawer.setFitsSystemWindows(false); }
@ColorInt public static int getDarkerColor(@ColorInt int color, @FloatRange(from = 0.0D, to = 1.0D) float transparency) { float[] hsv = new float[3]; Color.colorToHSV(color, hsv); hsv[2] *= transparency; return Color.HSVToColor(hsv); }
/** * 快速模糊图片 * <p>先缩小原图,对小图进行模糊,再放大回原先尺寸</p> * * @param src 源图片 * @param scale 缩放比例(0...1) * @param radius 模糊半径(0...25) * @param recycle 是否回收 * @return 模糊后的图片 */ public static Bitmap fastBlur(Bitmap src, @FloatRange(from = 0, to = 1, fromInclusive = false) float scale, @FloatRange(from = 0, to = 25, fromInclusive = false) float radius, boolean recycle) { if (isEmptyBitmap(src)) { return null; } int width = src.getWidth(); int height = src.getHeight(); int scaleWidth = (int) (width * scale + 0.5f); int scaleHeight = (int) (height * scale + 0.5f); if (scaleWidth == 0 || scaleHeight == 0) { return null; } Bitmap scaleBitmap = Bitmap .createScaledBitmap(src, scaleWidth, scaleHeight, true); Paint paint = new Paint( Paint.FILTER_BITMAP_FLAG | Paint.ANTI_ALIAS_FLAG); Canvas canvas = new Canvas(); PorterDuffColorFilter filter = new PorterDuffColorFilter(Color.TRANSPARENT, PorterDuff.Mode.SRC_ATOP); paint.setColorFilter(filter); canvas.scale(scale, scale); canvas.drawBitmap(scaleBitmap, 0, 0, paint); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { scaleBitmap = renderScriptBlur(ContextUtils .getContext(), scaleBitmap, radius); } else { scaleBitmap = stackBlur(scaleBitmap, (int) radius, recycle); } if (scale == 1) { return scaleBitmap; } Bitmap ret = Bitmap .createScaledBitmap(scaleBitmap, width, height, true); if (scaleBitmap != null && !scaleBitmap.isRecycled()) { scaleBitmap.recycle(); } if (recycle && !src.isRecycled()) { src.recycle(); } return ret; }
/** * * @param context Context * @param radius The blur's radius. * @param color The color filter for blurring. */ public BlurTransformation(Context context, @FloatRange(from = 0.0f) float radius, int color) { super(context); mContext = context; if (radius > MAX_RADIUS) { mSampling = radius / 25.0f; mRadius = MAX_RADIUS; } else { mRadius = radius; } mColor = color; }
/** * {@inheritDoc} */ @Override public void setLineDistance(@FloatRange(from = 0) final float lineDistance) { if (lineDistance < 0) { throw new IllegalArgumentException("line distance must not be negative"); } if (Float.compare(lineDistance, Float.NaN) == 0) { throw new IllegalArgumentException("line distance must be a valid float"); } mLineDistance = lineDistance; }
@ColorInt public static int setColorAlpha(@ColorInt int color, @FloatRange(from = 0.0D, to = 1.0D) float alpha) { int alpha2 = Math.round((float) Color.alpha(color) * alpha); int red = Color.red(color); int green = Color.green(color); int blue = Color.blue(color); return Color.argb(alpha2, red, green, blue); }
public static RippleDrawable createRipple(@NonNull Palette palette, @FloatRange(from = 0f, to = 1f) float darkAlpha, @FloatRange(from = 0f, to = 1f) float lightAlpha, @ColorInt int fallbackColor, boolean bounded) { int rippleColor = fallbackColor; if (palette != null) { // try the named swatches in preference order if (palette.getVibrantSwatch() != null) { rippleColor = ColorUtils.modifyAlpha(palette.getVibrantSwatch().getRgb(), darkAlpha); } else if (palette.getLightVibrantSwatch() != null) { rippleColor = ColorUtils.modifyAlpha(palette.getLightVibrantSwatch().getRgb(), lightAlpha); } else if (palette.getDarkVibrantSwatch() != null) { rippleColor = ColorUtils.modifyAlpha(palette.getDarkVibrantSwatch().getRgb(), darkAlpha); } else if (palette.getMutedSwatch() != null) { rippleColor = ColorUtils.modifyAlpha(palette.getMutedSwatch().getRgb(), darkAlpha); } else if (palette.getLightMutedSwatch() != null) { rippleColor = ColorUtils.modifyAlpha(palette.getLightMutedSwatch().getRgb(), lightAlpha); } else if (palette.getDarkMutedSwatch() != null) { rippleColor = ColorUtils.modifyAlpha(palette.getDarkMutedSwatch().getRgb(), darkAlpha); } } return new RippleDrawable(ColorStateList.valueOf(rippleColor), null, bounded ? new ColorDrawable(Color.WHITE) : null); }
public static void LABToXYZ(@FloatRange(from = 0.0d, to = 100.0d) double l, @FloatRange(from = -128.0d, to = 127.0d) double a, @FloatRange(from = -128.0d, to = 127.0d) double b, @NonNull double[] outXyz) { double fy = (16.0d + l) / 116.0d; double fx = (a / 500.0d) + fy; double fz = fy - (b / 200.0d); double tmp = Math.pow(fx, 3.0d); double xr = tmp > XYZ_EPSILON ? tmp : ((116.0d * fx) - 16.0d) / XYZ_KAPPA; double yr = l > 7.9996247999999985d ? Math.pow(fy, 3.0d) : l / XYZ_KAPPA; tmp = Math.pow(fz, 3.0d); double zr = tmp > XYZ_EPSILON ? tmp : ((116.0d * fz) - 16.0d) / XYZ_KAPPA; outXyz[0] = XYZ_WHITE_REFERENCE_X * xr; outXyz[1] = XYZ_WHITE_REFERENCE_Y * yr; outXyz[2] = XYZ_WHITE_REFERENCE_Z * zr; }
/** * 设置阴影 * * @param radius 阴影半径 * @param dx x轴偏移量 * @param dy y轴偏移量 * @param shadowColor 阴影颜色 * @return {@link SpanUtils} */ public SpanUtils setShadow(@FloatRange(from = 0, fromInclusive = false) final float radius, final float dx, final float dy, final int shadowColor) { this.shadowRadius = radius; this.shadowDx = dx; this.shadowDy = dy; this.shadowColor = shadowColor; return this; }
/** * 设置view的权重,总权重数为1 ,weightWidth范围(0.0f-1.0f) * */ public void setWeightWidth(@FloatRange(from = 0, to = 1)float weightWidth) { if(weightWidth<0){ weightWidth = 0; } if(!TextUtils.isEmpty(label)){ if(weightWidth>=1){ weightWidth = 0.5f; } } this.weightWidth = weightWidth; }
public static GradientDrawable create(@ColorInt int startColor, @ColorInt int endColor, int radius, @FloatRange(from = 0f, to = 1f) float centerX, @FloatRange(from = 0f, to = 1f) float centerY) { GradientDrawable gradientDrawable = new GradientDrawable(); gradientDrawable.setColors(new int[]{ startColor, endColor }); gradientDrawable.setGradientType(GradientDrawable.RADIAL_GRADIENT); gradientDrawable.setGradientRadius(radius); gradientDrawable.setGradientCenter(centerX, centerY); return gradientDrawable; }
public static void XYZToLAB(@FloatRange(from = 0.0d, to = 95.047d) double x, @FloatRange(from = 0.0d, to = 100.0d) double y, @FloatRange(from = 0.0d, to = 108.883d) double z, @NonNull double[] outLab) { if (outLab.length != 3) { throw new IllegalArgumentException("outLab must have a length of 3."); } x = pivotXyzComponent(x / XYZ_WHITE_REFERENCE_X); y = pivotXyzComponent(y / XYZ_WHITE_REFERENCE_Y); z = pivotXyzComponent(z / XYZ_WHITE_REFERENCE_Z); outLab[0] = Math.max(0.0d, (116.0d * y) - 16.0d); outLab[1] = 500.0d * (x - y); outLab[2] = 200.0d * (y - z); }
/** * Background stroke width (in pixels) */ public void setBackgroundStrokeWidth(@FloatRange(from = 0f, to = Float.MAX_VALUE) float width) { checkWidth(width); mBackgroundStrokePaint.setStrokeWidth(width); invalidateDrawRect(); invalidate(); }
/** * 快速模糊图片 * <p>先缩小原图,对小图进行模糊,再放大回原先尺寸</p> * * @param src 源图片 * @param scale 缩放比例(0...1) * @param radius 模糊半径(0...25) * @param recycle 是否回收 * @return 模糊后的图片 */ public static Bitmap fastBlur(Bitmap src, @FloatRange(from = 0, to = 1, fromInclusive = false) float scale, @FloatRange(from = 0, to = 25, fromInclusive = false) float radius, boolean recycle) { if (isEmptyBitmap(src)) return null; int width = src.getWidth(); int height = src.getHeight(); int scaleWidth = (int) (width * scale + 0.5f); int scaleHeight = (int) (height * scale + 0.5f); if (scaleWidth == 0 || scaleHeight == 0) return null; Bitmap scaleBitmap = Bitmap.createScaledBitmap(src, scaleWidth, scaleHeight, true); Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.ANTI_ALIAS_FLAG); Canvas canvas = new Canvas(); PorterDuffColorFilter filter = new PorterDuffColorFilter( Color.TRANSPARENT, PorterDuff.Mode.SRC_ATOP); paint.setColorFilter(filter); canvas.scale(scale, scale); canvas.drawBitmap(scaleBitmap, 0, 0, paint); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { scaleBitmap = renderScriptBlur(scaleBitmap, radius); } else { scaleBitmap = stackBlur(scaleBitmap, (int) radius, recycle); } if (scale == 1) return scaleBitmap; Bitmap ret = Bitmap.createScaledBitmap(scaleBitmap, width, height, true); if (scaleBitmap != null && !scaleBitmap.isRecycled()) scaleBitmap.recycle(); if (recycle && !src.isRecycled()) src.recycle(); return ret; }
/** 设置状态栏darkMode,字体颜色及icon变黑(目前支持MIUI6以上,Flyme4以上,Android M以上) */ public static void darkMode(Window window, int color, @FloatRange(from = 0.0, to = 1.0) float alpha) { if (isFlyme4Later()) { darkModeForFlyme4(window, true); immersive(window,color,alpha); } else if (isMIUI6Later()) { darkModeForMIUI6(window, true); immersive(window,color,alpha); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { darkModeForM(window, true); immersive(window, color, alpha); } else if (Build.VERSION.SDK_INT >= 19) { window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); setTranslucentView((ViewGroup) window.getDecorView(), color, alpha); } else { immersive(window, color, alpha); } // if (Build.VERSION.SDK_INT >= 21) { // window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); // window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); // window.setStatusBarColor(Color.TRANSPARENT); // } else if (Build.VERSION.SDK_INT >= 19) { // window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); // } // setTranslucentView((ViewGroup) window.getDecorView(), color, alpha); }
/** * Android4.4以上的沉浸式全屏模式 * 注: * 1.删除fitsSystemWindows属性:Android5.0以上使用该方法如果出现界面展示不正确,删除布局中所有fitsSystemWindows属性 * 或者调用forceFitsSystemWindows方法 * 2.不删除fitsSystemWindows属性:也可以区别处理,Android5.0以上使用自己的方式实现,不调用该方法 * * @param window 一般都是用于Activity的window,也可以是其他的例如Dialog,DialogFragment * @param alpha 透明栏透明度[0.0-1.0] */ public static void immersiveStatusBar(Window window, @FloatRange(from = 0.0, to = 1.0) float alpha) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { return; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(Color.TRANSPARENT); int systemUiVisibility = window.getDecorView().getSystemUiVisibility(); systemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; systemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE; window.getDecorView().setSystemUiVisibility(systemUiVisibility); } else { window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } ViewGroup decorView = (ViewGroup) window.getDecorView(); ViewGroup contentView = (ViewGroup) window.getDecorView() .findViewById(Window.ID_ANDROID_CONTENT); View rootView = contentView.getChildAt(0); int statusBarHeight = getStatusBarHeight(window.getContext()); if (rootView != null) { FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) rootView.getLayoutParams(); ViewCompat.setFitsSystemWindows(rootView, true); lp.topMargin = -statusBarHeight; rootView.setLayoutParams(lp); } setTranslucentView(decorView, alpha); }
@ColorInt public static int shiftColor(@ColorInt int color, @FloatRange(from = 0.0f, to = 2.0f) float by) { if (by == 1f) return color; int alpha = Color.alpha(color); float[] hsv = new float[3]; Color.colorToHSV(color, hsv); hsv[2] *= by; // value component return (alpha << 24) + (0x00ffffff & Color.HSVToColor(hsv)); }
/******************** radius *******************************/ public void setRadius(@FloatRange(from = 0) float radius) { this.mRadius = radius; mNormalBackground.setCornerRadius(mRadius); mPressedBackground.setCornerRadius(mRadius); mUnableBackground.setCornerRadius(mRadius); }
/** * @see GlideOptions#sizeMultiplier(float) */ @CheckResult public GlideRequest<TranscodeType> sizeMultiplier(@FloatRange(from = 0.0, to = 1.0) float arg0) { if (getMutableOptions() instanceof GlideOptions) { this.requestOptions = ((GlideOptions) getMutableOptions()).sizeMultiplier(arg0); } else { this.requestOptions = new GlideOptions().apply(this.requestOptions).sizeMultiplier(arg0); } return this; }
/** * 混合两种颜色的色值 * Blend {@code color1} and {@code color2} using the given ratio. * * @param ratio of which to blend. 0.0 will return {@code color1}, 0.5 will give an even blend, * 1.0 will return {@code color2}. */ public static @CheckResult @ColorInt int blendColors(@ColorInt int color1, @ColorInt int color2, @FloatRange(from = 0f, to = 1f) float ratio) { final float inverseRatio = 1f - ratio; float a = (Color.alpha(color1) * inverseRatio) + (Color.alpha(color2) * ratio); float r = (Color.red(color1) * inverseRatio) + (Color.red(color2) * ratio); float g = (Color.green(color1) * inverseRatio) + (Color.green(color2) * ratio); float b = (Color.blue(color1) * inverseRatio) + (Color.blue(color2) * ratio); return Color.argb((int) a, (int) r, (int) g, (int) b); }
/** * {@inheritDoc} */ @Override public void setStepMultiplier(@FloatRange(from = 0) final float stepMultiplier) { if (stepMultiplier < 0) { throw new IllegalArgumentException("step multiplier must not be nagative"); } if (Float.compare(stepMultiplier, Float.NaN) == 0) { throw new IllegalArgumentException("step multiplier must be a valid float"); } mStepMultiplier = stepMultiplier; }
private static Drawable createBgColor(Context context, @ColorInt int resBackgroundColor, @PressedMode.Mode int mode, @FloatRange(from = 0.0f, to = 1.0f) float alpha) { ColorDrawable colorDrawableNormal = new ColorDrawable(); ColorDrawable colorDrawablePressed = new ColorDrawable(); ColorDrawable colorDrawableUnable = new ColorDrawable(); colorDrawableNormal.setColor(resBackgroundColor); colorDrawablePressed.setColor(resBackgroundColor); colorDrawableUnable.setColor(resBackgroundColor); Drawable pressed = getPressedStateDrawable(context, mode, alpha, colorDrawablePressed); Drawable unable = getUnableStateDrawable(context, colorDrawableUnable); return createStateListDrawable(colorDrawableNormal, pressed, unable); }
public static void tintStatusBar(Activity activity, @ColorInt int statusBarColor, @FloatRange(from = 0.0, to = 1.0) float alpha) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { return; } Window window = activity.getWindow(); ViewGroup decorView = (ViewGroup) window.getDecorView(); ViewGroup contentView = (ViewGroup) window.getDecorView().findViewById(Window.ID_ANDROID_CONTENT); View rootView = contentView.getChildAt(0); if (rootView != null && !ViewCompat.getFitsSystemWindows(rootView)) { ViewCompat.setFitsSystemWindows(rootView, true); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); // window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); // window.setStatusBarColor(Color.TRANSPARENT); window.getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); if (statusBarColor != COLOR_INVALID_VAL) { window.setStatusBarColor(statusBarColor); } } else { window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); setStatusBar(decorView, statusBarColor, true); setTranslucentView(decorView, alpha); } }
public void setStartAngle(@FloatRange(from = 0.0, to = 360.0) float startAngle) { mStartAngle = startAngle; mAngle = 0; final float sw = mPaint.getStrokeWidth() * 0.5f; final float radius = mRadius - sw; mPath.reset(); final float x = (float) Math.cos(Math.toRadians(startAngle)) * radius; final float y = (float) Math.sin(Math.toRadians(startAngle)) * radius; mPath.moveTo(x, y); }
/** * 设置滑动阈值占屏幕高度的比例。也可使用{@link #slideThreshold(Integer, Integer, Integer)}来设置阈值 * * @param minHeightPercent 滑动布局最小显示高度占屏幕高度的比例,默认值为1/10。若不为null且大于0,则修改对应值。 * @param mediumHeightPercent 滑动布局中等显示高度占屏幕高度的比例,默认值为1/2。若不为null且大于0,则修改对应值。 * @param maxHeightPercent 滑动布局最大显示高度占屏幕高度的比例,默认值为9/10。若不为null且大于0,则修改对应值。 */ public Builder slidePercentThreshold(@Nullable @FloatRange(from = 0.0, to = 1.0) Float minHeightPercent, @Nullable @FloatRange(from = 0.0, to = 1.0) Float mediumHeightPercent, @Nullable @FloatRange(from = 0.0, to = 1.0) Float maxHeightPercent) { setMinHeightPercent(minHeightPercent); setMediumHeightPercent(mediumHeightPercent); setMaxHeightPercent(maxHeightPercent); return this; }
/** * Sets step multiplier. Use this to control speed. * * @param stepMultiplier step multiplier */ public void setStepMultiplier(@FloatRange(from = 0) final float stepMultiplier) { if (stepMultiplier < 0) { throw new IllegalArgumentException("step multiplier must not be nagative"); } mStepMultiplier = stepMultiplier; }
public static void blendHSL(@NonNull float[] hsl1, @NonNull float[] hsl2, @FloatRange(from = 0.0d, to = 1.0d) float ratio, @NonNull float[] outResult) { if (outResult.length != 3) { throw new IllegalArgumentException("result must have a length of 3."); } float inverseRatio = 1.0f - ratio; outResult[0] = circularInterpolate(hsl1[0], hsl2[0], ratio); outResult[1] = (hsl1[1] * inverseRatio) + (hsl2[1] * ratio); outResult[2] = (hsl1[2] * inverseRatio) + (hsl2[2] * ratio); }
public ms_AlertDialog setANegativeButtonSize(@FloatRange float size) { obtainANegativeButton().setTextSize(size); return this; }
public static void setAlpha(View view, @FloatRange(from = 0.0d, to = 1.0d) float value) { IMPL.setAlpha(view, value); }
public static Drawable createBgDrawableWithDarkMode(@NonNull Context context, @DrawableRes int res, @FloatRange(from = 0.0f, to = 1.0f) float alpha) { return createBgDrawable(context, res, PressedMode.DARK, alpha); }
@ColorInt public static int LABToColor(@FloatRange(from = 0.0d, to = 100.0d) double l, @FloatRange(from = -128.0d, to = 127.0d) double a, @FloatRange(from = -128.0d, to = 127.0d) double b) { double[] result = getTempDouble3Array(); LABToXYZ(l, a, b, result); return XYZToColor(result[0], result[1], result[2]); }