728x90
Gradle Dependency추가
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
대부분 아시겠지만 Gradle을 변경하면 Sync를 꼭 해줘야 합니다.
모든라이브러리 공통사항이에요. Dependency추가하고 Sync를 해줘야
Glide입력하고 Alt + Enter를 눌렀을 때 Import class를 할 수 있습니다.
이미지를 담을 뷰 생성
<ImageView
android:id="@+id/example"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
drawable폴더안에 이미지를 넣어주세요.
이미지파일의 이름에는 대문자가 들어가면 에러가 난답니다.
ImageView example=findViewById(R.id.example);
Glide.with(this)
.load(R.drawable.mario)
.into(example);
성공 ~!
with()에는 context가 들어갑니다.
load()에는 이미지 경로
into()에는 이미지를 띄울 뷰입니다.
추가적으로
Glide를 쓰는 이유
1. 이미지를 다룰 수 있는 기능이 많습니다. 이미지 크기조절, CropCircle등
2. Url, 상대경로, 절대경로 가리지 않고 띄울수 있음
'개발 이야기' 카테고리의 다른 글
클래스(class)란 무엇인가? (0) | 2023.06.21 |
---|---|
서버의 개념에 대해 (0) | 2023.06.21 |
[C++]반복문을 이용한 도형그리기 (0) | 2023.06.04 |
ChatGPT에 대한 신뢰의 문제 (0) | 2023.06.03 |
블로그 글이 복사(ctrl + c)가 안될 때 해결 법 (0) | 2023.05.30 |