当前位置: 首页>>代码示例>>Java>>正文


Java RoundingParams.setOverlayColor方法代码示例

本文整理汇总了Java中com.facebook.drawee.generic.RoundingParams.setOverlayColor方法的典型用法代码示例。如果您正苦于以下问题:Java RoundingParams.setOverlayColor方法的具体用法?Java RoundingParams.setOverlayColor怎么用?Java RoundingParams.setOverlayColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.facebook.drawee.generic.RoundingParams的用法示例。


在下文中一共展示了RoundingParams.setOverlayColor方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: changeDraweeViewScaleType

import com.facebook.drawee.generic.RoundingParams; //导入方法依赖的package包/类
private void changeDraweeViewScaleType(
    SimpleDraweeView draweeView,
    ScaleType scaleType,
    @Nullable PointF focusPoint) {
  final GenericDraweeHierarchy hierarchy = draweeView.getHierarchy();
  hierarchy.setActualImageScaleType(scaleType);
  hierarchy.setActualImageFocusPoint(focusPoint != null ? focusPoint : new PointF(0.5f, 0.5f));

  final RoundingParams roundingParams = Preconditions.checkNotNull(hierarchy.getRoundingParams());
  if (BITMAP_ONLY_SCALETYPES.contains(scaleType)) {
    roundingParams.setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY);
  } else {
    roundingParams.setOverlayColor(mWindowBackgroundColor);
  }
  hierarchy.setRoundingParams(roundingParams);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:DraweeRoundedCornersFragment.java

示例2: maybeUpdateView

import com.facebook.drawee.generic.RoundingParams; //导入方法依赖的package包/类
public void maybeUpdateView() {
  if (!mIsDirty) {
    return;
  }

  boolean doResize = shouldResize(mUri);
  if (doResize && (getWidth() <= 0 || getHeight() <=0)) {
    // If need a resize and the size is not yet set, wait until the layout pass provides one
    return;
  }

  GenericDraweeHierarchy hierarchy = getHierarchy();
  hierarchy.setActualImageScaleType(mScaleType);

  if (mLoadingImageDrawable != null) {
    hierarchy.setPlaceholderImage(mLoadingImageDrawable, ScalingUtils.ScaleType.CENTER);
  }

  boolean usePostprocessorScaling =
      mScaleType != ScalingUtils.ScaleType.CENTER_CROP &&
      mScaleType != ScalingUtils.ScaleType.FOCUS_CROP;
  float hierarchyRadius = usePostprocessorScaling ? 0 : mBorderRadius;

  RoundingParams roundingParams = hierarchy.getRoundingParams();
  roundingParams.setCornersRadius(hierarchyRadius);
  roundingParams.setBorder(mBorderColor, mBorderWidth);
  if (mOverlayColor != Color.TRANSPARENT) {
      roundingParams.setOverlayColor(mOverlayColor);
  } else {
      // make sure the default rounding method is used.
      roundingParams.setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY);
  }
  hierarchy.setRoundingParams(roundingParams);
  hierarchy.setFadeDuration(
      mFadeDurationMs >= 0
          ? mFadeDurationMs
          : mIsLocalImage ? 0 : REMOTE_IMAGE_FADE_DURATION_MS);

  Postprocessor postprocessor = usePostprocessorScaling ? mRoundedCornerPostprocessor : null;

  ResizeOptions resizeOptions = doResize ? new ResizeOptions(getWidth(), getHeight()) : null;

  ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(mUri)
      .setPostprocessor(postprocessor)
      .setResizeOptions(resizeOptions)
      .setAutoRotateEnabled(true)
      .setProgressiveRenderingEnabled(mProgressiveRenderingEnabled)
      .build();

  // This builder is reused
  mDraweeControllerBuilder.reset();

  mDraweeControllerBuilder
      .setAutoPlayAnimations(true)
      .setCallerContext(mCallerContext)
      .setOldController(getController())
      .setImageRequest(imageRequest);

  if (mControllerListener != null && mControllerForTesting != null) {
    ForwardingControllerListener combinedListener = new ForwardingControllerListener();
    combinedListener.addListener(mControllerListener);
    combinedListener.addListener(mControllerForTesting);
    mDraweeControllerBuilder.setControllerListener(combinedListener);
  } else if (mControllerForTesting != null) {
    mDraweeControllerBuilder.setControllerListener(mControllerForTesting);
  } else if (mControllerListener != null) {
    mDraweeControllerBuilder.setControllerListener(mControllerListener);
  }

  setController(mDraweeControllerBuilder.build());
  mIsDirty = false;
}
 
开发者ID:john1jan,项目名称:ReactNativeSignatureExample,代码行数:73,代码来源:ReactImageView.java

示例3: maybeUpdateView

import com.facebook.drawee.generic.RoundingParams; //导入方法依赖的package包/类
public void maybeUpdateView() {
  if (!mIsDirty) {
    return;
  }

  boolean doResize = shouldResize(mUri);
  if (doResize && (getWidth() <= 0 || getHeight() <=0)) {
    // If need a resize and the size is not yet set, wait until the layout pass provides one
    return;
  }

  GenericDraweeHierarchy hierarchy = getHierarchy();
  hierarchy.setActualImageScaleType(mScaleType);

  if (mLoadingImageDrawable != null) {
    hierarchy.setPlaceholderImage(mLoadingImageDrawable, ScalingUtils.ScaleType.CENTER);
  }

  boolean usePostprocessorScaling =
      mScaleType != ScalingUtils.ScaleType.CENTER_CROP &&
      mScaleType != ScalingUtils.ScaleType.FOCUS_CROP;

  RoundingParams roundingParams = hierarchy.getRoundingParams();

  if (usePostprocessorScaling) {
    roundingParams.setCornersRadius(0);
  } else {
    cornerRadii(sComputedCornerRadii);

    roundingParams.setCornersRadii(sComputedCornerRadii[0], sComputedCornerRadii[1], sComputedCornerRadii[2], sComputedCornerRadii[3]);
  }

  roundingParams.setBorder(mBorderColor, mBorderWidth);
  if (mOverlayColor != Color.TRANSPARENT) {
      roundingParams.setOverlayColor(mOverlayColor);
  } else {
      // make sure the default rounding method is used.
      roundingParams.setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY);
  }
  hierarchy.setRoundingParams(roundingParams);
  hierarchy.setFadeDuration(
      mFadeDurationMs >= 0
          ? mFadeDurationMs
          : mIsLocalImage ? 0 : REMOTE_IMAGE_FADE_DURATION_MS);

  Postprocessor postprocessor = usePostprocessorScaling ? mRoundedCornerPostprocessor : null;

  ResizeOptions resizeOptions = doResize ? new ResizeOptions(getWidth(), getHeight()) : null;

  ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(mUri)
      .setPostprocessor(postprocessor)
      .setResizeOptions(resizeOptions)
      .setAutoRotateEnabled(true)
      .setProgressiveRenderingEnabled(mProgressiveRenderingEnabled)
      .build();

  // This builder is reused
  mDraweeControllerBuilder.reset();

  mDraweeControllerBuilder
      .setAutoPlayAnimations(true)
      .setCallerContext(mCallerContext)
      .setOldController(getController())
      .setImageRequest(imageRequest);

  if (mControllerListener != null && mControllerForTesting != null) {
    ForwardingControllerListener combinedListener = new ForwardingControllerListener();
    combinedListener.addListener(mControllerListener);
    combinedListener.addListener(mControllerForTesting);
    mDraweeControllerBuilder.setControllerListener(combinedListener);
  } else if (mControllerForTesting != null) {
    mDraweeControllerBuilder.setControllerListener(mControllerForTesting);
  } else if (mControllerListener != null) {
    mDraweeControllerBuilder.setControllerListener(mControllerListener);
  }

  setController(mDraweeControllerBuilder.build());
  mIsDirty = false;
}
 
开发者ID:ManrajGrover,项目名称:react-native-box-loaders,代码行数:80,代码来源:ReactImageView.java

示例4: maybeUpdateView

import com.facebook.drawee.generic.RoundingParams; //导入方法依赖的package包/类
public void maybeUpdateView() {
    if (!mIsDirty) {
        return;
    }

    boolean doResize = shouldResize(mUri);
    if (doResize && (getWidth() <= 0 || getHeight() <= 0)) {
        // If need a resize and the size is not yet set, wait until the layout pass provides one
        return;
    }

    GenericDraweeHierarchy hierarchy = getHierarchy();
    hierarchy.setActualImageScaleType(mScaleType);

    if (mLoadingImageDrawable != null) {
        hierarchy.setPlaceholderImage(mLoadingImageDrawable, ScalingUtils.ScaleType.CENTER);
    }

    boolean usePostprocessorScaling =
            mScaleType != ScalingUtils.ScaleType.CENTER_CROP &&
                    mScaleType != ScalingUtils.ScaleType.FOCUS_CROP;
    float hierarchyRadius = usePostprocessorScaling ? 0 : mBorderRadius;

    RoundingParams roundingParams = hierarchy.getRoundingParams();
    roundingParams.setCornersRadius(hierarchyRadius);
    roundingParams.setBorder(mBorderColor, mBorderWidth);
    if (mOverlayColor != Color.TRANSPARENT) {
        roundingParams.setOverlayColor(mOverlayColor);
    } else {
        // make sure the default rounding method is used.
        roundingParams.setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY);
    }
    hierarchy.setRoundingParams(roundingParams);
    hierarchy.setFadeDuration(
            mFadeDurationMs >= 0
                    ? mFadeDurationMs
                    : mIsLocalImage ? 0 : REMOTE_IMAGE_FADE_DURATION_MS);

    Postprocessor postprocessor = usePostprocessorScaling ? mRoundedCornerPostprocessor : null;

    ResizeOptions resizeOptions = doResize ? new ResizeOptions(getWidth(), getHeight()) : null;

    ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(mUri)
            .setPostprocessor(postprocessor)
            .setResizeOptions(resizeOptions)
            .setAutoRotateEnabled(true)
            .setProgressiveRenderingEnabled(mProgressiveRenderingEnabled)
            .build();

    // This builder is reused
    mDraweeControllerBuilder.reset();

    mDraweeControllerBuilder
            .setAutoPlayAnimations(true)
            .setCallerContext(mCallerContext)
            .setOldController(getController())
            .setImageRequest(imageRequest);

    if (mControllerListener != null && mControllerForTesting != null) {
        ForwardingControllerListener combinedListener = new ForwardingControllerListener();
        combinedListener.addListener(mControllerListener);
        combinedListener.addListener(mControllerForTesting);
        mDraweeControllerBuilder.setControllerListener(combinedListener);
    } else if (mControllerForTesting != null) {
        mDraweeControllerBuilder.setControllerListener(mControllerForTesting);
    } else if (mControllerListener != null) {
        mDraweeControllerBuilder.setControllerListener(mControllerListener);
    }

    setController(mDraweeControllerBuilder.build());
    mIsDirty = false;
}
 
开发者ID:bylevel,项目名称:react-native-image-android,代码行数:73,代码来源:ImageAndroidView.java

示例5: initView

import com.facebook.drawee.generic.RoundingParams; //导入方法依赖的package包/类
private void initView() {

        //获取SimpleDraweeView
        sdv = (SimpleDraweeView) findViewById(R.id.main_sdv);

        //初始化圆角圆形参数对象
        RoundingParams rp = new RoundingParams();
        //设置图像是否为圆形
        rp.setRoundAsCircle(true);
        //设置圆角半径
        //rp.setCornersRadius(20);
        //分别设置左上角、右上角、左下角、右下角的圆角半径
        //rp.setCornersRadii(20,25,30,35);
        //分别设置(前2个)左上角、(3、4)右上角、(5、6)左下角、(7、8)右下角的圆角半径
        //rp.setCornersRadii(new float[]{20,25,30,35,40,45,50,55});
        //设置边框颜色及其宽度
        rp.setBorder(Color.BLACK, 10);
        //设置叠加颜色
        rp.setOverlayColor(Color.GRAY);
        //设置圆形圆角模式
        //rp.setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY);
        //设置圆形圆角模式
        rp.setRoundingMethod(RoundingParams.RoundingMethod.OVERLAY_COLOR);

        //获取GenericDraweeHierarchy对象
        GenericDraweeHierarchy hierarchy = GenericDraweeHierarchyBuilder.newInstance(getResources())
                //设置圆形圆角参数
                .setRoundingParams(rp)
                //设置圆角半径
                //.setRoundingParams(RoundingParams.fromCornersRadius(20))
                //分别设置左上角、右上角、左下角、右下角的圆角半径
                //.setRoundingParams(RoundingParams.fromCornersRadii(20,25,30,35))
                //分别设置(前2个)左上角、(3、4)右上角、(5、6)左下角、(7、8)右下角的圆角半径
                //.setRoundingParams(RoundingParams.fromCornersRadii(new float[]{20,25,30,35,40,45,50,55}))
                //设置圆形圆角参数;RoundingParams.asCircle()是将图像设置成圆形
                //.setRoundingParams(RoundingParams.asCircle())
                //设置淡入淡出动画持续时间(单位:毫秒ms)
                .setFadeDuration(5000)
                //构建
                .build();

        //设置Hierarchy
        sdv.setHierarchy(hierarchy);

        //构建Controller
        DraweeController controller = Fresco.newDraweeControllerBuilder()
                //设置需要下载的图片地址
                .setUri(imageUrl)
                //设置点击重试是否开启
                .setTapToRetryEnabled(true)
                //构建
                .build();

        //设置Controller
        sdv.setController(controller);
    }
 
开发者ID:scp504677840,项目名称:Fresco,代码行数:57,代码来源:MainActivity.java

示例6: setCircle

import com.facebook.drawee.generic.RoundingParams; //导入方法依赖的package包/类
/**
 * 当设置roundAsCircle为true无效时,采用这个方法,常用在gif的圆形效果上
 *
 * 或者在xml中设置:fresco:roundWithOverlayColor="@color/you_color_id"
 "you_color_id"是指你的背景色,这样也可以实现圆角、圆圈效果
 *
 *roundAsCircle的局限性:
 * 当使用BITMAP_ONLY(默认)模式时的限制:
 并非所有的图片分支部分都可以实现圆角,目前只有占位图片和实际图片可以实现圆角,我们正在努力为背景图片实现圆角功能。
 只有BitmapDrawable 和 ColorDrawable类的图片可以实现圆角。我们目前不支持包括NinePatchDrawable和 ShapeDrawable在内的其他类型图片。(无论他们是在XML或是程序中声明的)
 动画不能被圆角。
 由于Android的BitmapShader的限制,当一个图片不能覆盖全部的View的时候,边缘部分会被重复显示,而非留白。对这种情况可以使用不同的缩放类型
 (比如centerCrop)来保证图片覆盖了全部的View。 OVERLAY_COLOR模式没有上述限制,但由于这个模式使用在图片上覆盖一个纯色图层的方式来模拟圆角效果,
 因此只有在图标背景是静止的并且与图层同色的情况下才能获得较好的效果。
 * @param draweeView
 * @param bgColor 圆形遮罩的颜色,应该与背景色一致
 */
public static void setCircle( SimpleDraweeView draweeView,int bgColor){
    RoundingParams roundingParams = RoundingParams.asCircle();//这个方法在某些情况下无法成圆,比如gif
    roundingParams.setOverlayColor(bgColor);//加一层遮罩
    draweeView.getHierarchy().setRoundingParams(roundingParams);
}
 
开发者ID:glassLake,项目名称:fastDev,代码行数:23,代码来源:FrescoUtils.java

示例7: setCircle

import com.facebook.drawee.generic.RoundingParams; //导入方法依赖的package包/类
/**
 * 当设置roundAsCircle为true无效时,采用这个方法,常用在gif的圆形效果上
 *
 * 或者在xml中设置:fresco:roundWithOverlayColor="@color/you_color_id"
 "you_color_id"是指你的背景色,这样也可以实现圆角、圆圈效果
 *
 *roundAsCircle的局限性:
 * 当使用BITMAP_ONLY(默认)模式时的限制:

 并非所有的图片分支部分都可以实现圆角,目前只有占位图片和实际图片可以实现圆角,我们正在努力为背景图片实现圆角功能。
 只有BitmapDrawable 和 ColorDrawable类的图片可以实现圆角。我们目前不支持包括NinePatchDrawable和 ShapeDrawable在内的其他类型图片。(无论他们是在XML或是程序中声明的)
 动画不能被圆角。
 由于Android的BitmapShader的限制,当一个图片不能覆盖全部的View的时候,边缘部分会被重复显示,而非留白。对这种情况可以使用不同的缩放类型
 (比如centerCrop)来保证图片覆盖了全部的View。 OVERLAY_COLOR模式没有上述限制,但由于这个模式使用在图片上覆盖一个纯色图层的方式来模拟圆角效果,
 因此只有在图标背景是静止的并且与图层同色的情况下才能获得较好的效果。
 * @param draweeView
 * @param bgColor 圆形遮罩的颜色,应该与背景色一致
 */
public static void setCircle(SimpleDraweeView draweeView, @ColorInt int bgColor){
    RoundingParams roundingParams = RoundingParams.asCircle();//这个方法在某些情况下无法成圆,比如gif
    roundingParams.setOverlayColor(bgColor);//加一层遮罩
    draweeView.getHierarchy().setRoundingParams(roundingParams);
}
 
开发者ID:hss01248,项目名称:MyImageUtil,代码行数:24,代码来源:FrescoUtil.java

示例8: setCircle

import com.facebook.drawee.generic.RoundingParams; //导入方法依赖的package包/类
/**
 * 当设置roundAsCircle为true无效时,采用这个方法,常用在gif的圆形效果上
 *
 * 或者在xml中设置:fresco:roundWithOverlayColor="@color/you_color_id"
 "you_color_id"是指你的背景色,这样也可以实现圆角、圆圈效果
 *
 *roundAsCircle的局限性:
 * 当使用BITMAP_ONLY(默认)模式时的限制:

 并非所有的图片分支部分都可以实现圆角,目前只有占位图片和实际图片可以实现圆角,我们正在努力为背景图片实现圆角功能。
 只有BitmapDrawable 和 ColorDrawable类的图片可以实现圆角。我们目前不支持包括NinePatchDrawable和 ShapeDrawable在内的其他类型图片。(无论他们是在XML或是程序中声明的)
 动画不能被圆角。
 由于Android的BitmapShader的限制,当一个图片不能覆盖全部的View的时候,边缘部分会被重复显示,而非留白。对这种情况可以使用不同的缩放类型
 (比如centerCrop)来保证图片覆盖了全部的View。 OVERLAY_COLOR模式没有上述限制,但由于这个模式使用在图片上覆盖一个纯色图层的方式来模拟圆角效果,
 因此只有在图标背景是静止的并且与图层同色的情况下才能获得较好的效果。
 * @param draweeView
 * @param bgColor 圆形遮罩的颜色,应该与背景色一致
 */
public static void setCircle( SimpleDraweeView draweeView,int bgColor){
    RoundingParams roundingParams = RoundingParams.asCircle();//这个方法在某些情况下无法成圆,比如gif
    roundingParams.setOverlayColor(bgColor);//加一层遮罩
    draweeView.getHierarchy().setRoundingParams(roundingParams);
}
 
开发者ID:glassLake,项目名称:FrescoUtlis,代码行数:24,代码来源:FrescoUtils.java


注:本文中的com.facebook.drawee.generic.RoundingParams.setOverlayColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。