Java Code Examples for com.facebook.drawee.generic.RoundingParams#setBorder()

The following examples show how to use com.facebook.drawee.generic.RoundingParams#setBorder() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DraweeRoundedCornersFragment.java    From fresco with MIT License 5 votes vote down vote up
private void setShowBorder(SimpleDraweeView draweeView, boolean show, boolean scaleInside) {
  final RoundingParams roundingParams =
      Preconditions.checkNotNull(draweeView.getHierarchy().getRoundingParams());
  if (show) {
    roundingParams.setBorder(
        mColorPrimary,
        getResources().getDimensionPixelSize(R.dimen.drawee_rounded_corners_border_width));
    roundingParams.setScaleDownInsideBorders(scaleInside);
  } else {
    roundingParams.setBorder(Color.TRANSPARENT, 0);
  }
  draweeView.getHierarchy().setRoundingParams(roundingParams);
}
 
Example 2
Source File: MainActivity.java    From Fresco with Apache License 2.0 4 votes vote down vote up
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);
    }