Created
March 28, 2020 12:16
-
-
Save monkeydone/9bd2f4b0d0a5a1f278eaed2734a7be88 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
ViewOutlineProvider实现圆角 | |
roundImage.setOutlineProvider(new ViewOutlineProvider() { | |
@Override | |
public void getOutline(View view, Outline outline) { | |
outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), 30); | |
} | |
}); | |
roundImage.setClipToOutline(true); | |
复制代码ViewOutlineProvider实现圆形 | |
circleImage.setOutlineProvider(new ViewOutlineProvider() { | |
@Override | |
public void getOutline(View view, Outline outline) { | |
outline.setOval(0, 0, view.getWidth(), view.getHeight()); | |
} | |
}); | |
circleImage.setClipToOutline(true); | |
复制代码setClipToOutline方法可以在前设置也可以在为设置,如果设置为false则表示禁止裁剪,setOutlineProvider方法将无效。 | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment