Android/Kotlin
[Android][Kotlin] ImageView 코너 둥글리기 (라운딩)
yoo.o
2020. 7. 7. 01:25
반응형
이미지뷰의 코너를 둥글게 해주는 코드
새로운 drawable 생성해주기
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:radius="10dp"/>
</shape>
둥글게 하고 싶은 이미지뷰의 백그라운드에 아까 생성한 drawable을 설정해주고 setClipToOutline()을 해주면 된다
// 코너 라운딩 (radius: 10dp)
IMAGEVIEW.background = getResources().getDrawable(R.drawable.imageview_cornerround, null)
IMAGEVIEW.setClipToOutline(true)
반응형