ViewOutlineProvider 改变View的外形
改方法仅在5.0之后有效
使用方式
ImageView iv2 = findViewById(R.id.iv2);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
iv2.setClipToOutline(true);
iv2.setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
outline.setOval(0, 0, view.getWidth(), view.getHeight());
}
}
});
}
网友评论