메뉴 건너뛰기

?

단축키

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
번호 제목 날짜 조회 수
257 버튼 이벤트 추가하기 file 2021.03.31 191
256 안드로이드 스튜디오 - 필수 재정의 함수 자동 코드 추가 file 2021.03.29 194
255 버튼 이벤트 file 2021.03.31 205
254 안드로이드 - 컨텍스트 메뉴(Context Menu) 사용 예제 file 2021.04.01 207
253 안드로이드 액티비티 세로고정 2021.09.14 207
252 안드로이드 - 인텐트(Intent)를 활용한 액티비티(Activity) 생성 및 실행하기 file 2021.03.31 213
251 안드로이드 - 액티비티(Activity)와 액티비티 생명 주기(Activity Life Cycle) file 2021.04.01 225
250 안드로이드 - setContentView()와 레이아웃 전개자(LayoutInflater) 2021.04.01 227
249 안드로이드 가상머신 실행 속도 빠르게 하기 file 2021.03.31 228
248 버튼 생성, 이벤트 처리 file 2021.03.31 236
247 안드로이드 - 스타일 리소스(Style Resource) 사용하기 <style> file 2021.03.31 238
246 안드로이드 - 랠러티브 레이아웃(Relative Layout) file 2021.03.29 239
245 This Handler class should be static or leaks might occur 시 해결법 2020.12.14 240
244 Fragment를 통한 하단탭 예제1 file 2020.12.14 242
243 App 실행 file 2021.03.31 244
242 안드로이드 - SQLiteDatabase 구현하기 file 2021.04.01 249
241 Virtual Device , 디자인 화면 file 2021.03.31 260
240 setContentView()와 레이아웃 전개자(LayoutInflater) 2021.03.31 266
239 안드로이드 - AsyncTask 구현 예제 file 2021.04.01 280
238 안드로이드 - 익명 클래스(Anonymous Class) 사용법 file 2021.03.31 281
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 13 Next
/ 13

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

© k2s0o1d4e0s2i1g5n. All Rights Reserved