Android Glide加载四周圆角图

Android Glide加载四周圆角图


需要引入:
implementation 'jp.wasabeef:glide-transformations:3.3.0'

上层Java代码:
package zhangphil.test;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.ImageView;

import com.bumptech.glide.Glide;

import jp.wasabeef.glide.transformations.RoundedCornersTransformation;

import static com.bumptech.glide.request.RequestOptions.bitmapTransform;

public class GlideActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_glide);

        String url = "https://avatar.csdn.net/9/7/A/3_zhangphil.jpg";

        // 原图处理成圆角.
        // 如果是四周都是圆角则是RoundedCornersTransformation.CornerType.ALL
        ImageView image = findViewById(R.id.image);
        Glide.with(this)
                .load(url)
                .apply(bitmapTransform(new RoundedCornersTransformation(200, 0, RoundedCornersTransformation.CornerType.ALL)))
                .into(image);
    }
}


运行结果输出:
Android Glide加载四周圆角图_第1张图片



需要添加权限:

<uses-permission android:name="android.permission.INTERNET"/>

你可能感兴趣的:(Android,Android,Glide详解)