메뉴 건너뛰기

?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

안드로이드 상에서 URL 웹주소로 되어 있는 이미지를 그대로 불러오고 싶을때, 몇가지 라이브러리 파일이 있는데,

필자는 Glide 를 사용해 보았다.

정말 사용법이 간단하다.

 

https://github.com/bumptech/glide

http://bumptech.github.io/glide/doc/download-setup.html#jar

 

 

1. build.gradel (app) 에서 아래 jar 를 추가한다.

    dependencies {
     implementation 'com.github.bumptech.glide:glide:4.9.0'
     annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
    }

버전 숫자는 최신버전, 구버전다 상관없이 잘 돌아간다.

 

2. AndroidManifest.xml 파일내 웹접근이 가능하도록 퍼미션 추가한다.

<uses-permission android:name="android.permission.INTERNET"/>

3. xml 디자인 소스에 ImageView 를 올려 놓는다. 

보통의 경우 activity_main.xml 을 기준으로 올려 본다.

1
2
3
4
5
6
7
8
9
10
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
 
       <ImageView
            android:id="@+id/imageView1"
            android:layout_width="80dp"
            android:layout_height="80dp"/>
 
</LinearLayout>
cs

 

4. java 파일에서 직접 사용해 본다. (MainActivity.java)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
public class MainActivity extends AppCompatActivity {
 
    private ImageView imageView1;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        imageView1 = findViewById(R.id.imageView1);
 
 
        String imageStr = "http://도메인주소/image/abc.png";
        Glide.with(this).load(imageStr).into(imageView1);
 
    }
}
 
cs

 


List of Articles
번호 제목 날짜 조회 수
217 안드로이드 - Serializable를 활용한 다른 액티비티에 객체(Object) 전달하기 file 2021.03.31 281
216 안드로이드 - 인텐트(Intent)를 활용한 액티비티(Activity)간 데이터 전달하기 file 2021.03.31 349
215 안드로이드 - 인텐트(Intent)를 활용한 액티비티(Activity) 생성 및 실행하기 file 2021.03.31 223
214 안드로이드 - 스타일 리소스(Style Resource) 사용하기 <style> file 2021.03.31 238
213 안드로이드 - 색상 리소스 (Color Resource) 추가 </color> file 2021.03.31 551
212 안드로이드 - 문자열 배열 리소스 추가하기 <string-array> file 2021.03.31 820
211 안드로이드 - 문자열 리소스를 활용한 다국어 지원 file 2021.03.31 286
210 안드로이드 - 문자열 리소스(Resource) 추가 및 참조하기 file 2021.03.31 907
209 안드로이드 - 텍스트뷰(TextView) 사용법 정리 file 2021.03.31 1255
208 안드로이드 - 버튼 이벤트 처리방법 정리 (리스너 구현 및 이벤트 핸들링) file 2021.03.31 343
207 안드로이드 - 익명 클래스(Anonymous Class) 사용법 file 2021.03.31 286
206 setContentView()와 레이아웃 전개자(LayoutInflater) 2021.03.31 266
205 버튼 이벤트 추가하기 file 2021.03.31 194
204 안드로이드 가상머신 실행 속도 빠르게 하기 file 2021.03.31 228
203 버튼 이벤트 file 2021.03.31 205
202 App 실행 file 2021.03.31 244
201 Virtual Device , 디자인 화면 file 2021.03.31 260
200 Java에서 XML 불러와서 동적 변화 주기 file 2021.03.31 288
199 버튼 생성, 이벤트 처리 file 2021.03.31 236
198 안드로이드 - 에디트텍스트(EditText) 사용법 정리 file 2021.03.29 2769
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 13 Next
/ 13

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved