메뉴 건너뛰기

?

단축키

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
번호 제목 날짜 조회 수
57 Virtual Device , 디자인 화면 file 2021.03.31 260
56 App 실행 file 2021.03.31 244
55 버튼 이벤트 file 2021.03.31 205
54 안드로이드 가상머신 실행 속도 빠르게 하기 file 2021.03.31 228
53 버튼 이벤트 추가하기 file 2021.03.31 194
52 setContentView()와 레이아웃 전개자(LayoutInflater) 2021.03.31 266
51 안드로이드 - 익명 클래스(Anonymous Class) 사용법 file 2021.03.31 286
50 안드로이드 - 버튼 이벤트 처리방법 정리 (리스너 구현 및 이벤트 핸들링) file 2021.03.31 344
49 안드로이드 - 텍스트뷰(TextView) 사용법 정리 file 2021.03.31 1257
48 안드로이드 - 문자열 리소스(Resource) 추가 및 참조하기 file 2021.03.31 907
47 안드로이드 - 문자열 리소스를 활용한 다국어 지원 file 2021.03.31 286
46 안드로이드 - 문자열 배열 리소스 추가하기 <string-array> file 2021.03.31 821
45 안드로이드 - 색상 리소스 (Color Resource) 추가 </color> file 2021.03.31 551
44 안드로이드 - 스타일 리소스(Style Resource) 사용하기 <style> file 2021.03.31 238
43 안드로이드 - 인텐트(Intent)를 활용한 액티비티(Activity) 생성 및 실행하기 file 2021.03.31 223
42 안드로이드 - 인텐트(Intent)를 활용한 액티비티(Activity)간 데이터 전달하기 file 2021.03.31 349
41 안드로이드 - Serializable를 활용한 다른 액티비티에 객체(Object) 전달하기 file 2021.03.31 281
40 안드로이드 - 액티비티(Activity)로부터 결과 데이터 받아오기 file 2021.03.31 483
39 안드로이드 - 토스트(Toast) 메시지 사용하기. file 2021.03.31 325
38 안드로이드 - SnackBar를 사용해 팝업창 띄우기 file 2021.03.31 282
Board Pagination Prev 1 ... 4 5 6 7 8 9 10 11 12 13 Next
/ 13

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

© k2s0o1d4e0s2i1g5n. All Rights Reserved