개발 창고/Android
[Kotlin] drawable resource 불러오기
로이제로
2023. 2. 21. 22:00
반응형
val image: Bitmap = BitmapFactory.decodeResource(resources, R.drawable.bg_metal)
만약 아래와 같이 app > src > res > drawable에 있는 이미지 파일(bg_metal.png)을 불러와 사용하는 경우
Java source의 경우 아래와 같이 Bitmap으로 불러와 사용 가능하며
Bitmap image = BitmapFactory.decodeResource(context.getResources(), R.drawable.bg_metal); |
Kotlin의 경우 아래와 같이 호출하여 사용 가능합니다.
val image: Bitmap = BitmapFactory.decodeResource(resources, R.drawable.bg_metal) |
반응형