본문 바로가기
Front-end/Android (안드로이드 앱 개발)

Android studio (안드로이드 스튜디오) Library 라이브러리 추가하기 ex) Glide 글라이드

by javapp 자바앱 2020. 2. 29.
728x90

 Library 라이브러리 추가하기 

 

AndroidManifset.xml

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

Gradle (원격 방식)

사용 방법: github 다운로드에서 코드 복사 붙이기

< build.gatdle(project:Fragment) >

buildscript{

          ...

}

< build.gradle(Module: app) >

dependencies{

..

complie à implementation

}

sync now 클릭

Glide

 


Glide 사용 방식

// URL

Glide.with(fragment).load("url").into(imageView);

 

// Resource ID

int resourceId = R.mipmap.ic_launcher;

Glide.with(fragment).load(resourceId).into(imageView);

 

// Local file

File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "example.jpg");

Glid.with(fragment).load(file).into(imageView);

 

//URI

Uri uri = Uri.parse("android.resource://com.example.test/resource");

Glid.with(fragment).load(uri).into(imageView);

[출처] https://blog.naver.com/neta6603/221678827709

 


protected void onCreate(Bundle savedInstanceState) {
   
super.onCreate(savedInstanceState);
    setContentView(R.layout.
activity_main);
   
context = this;
    String url;
   
imageView1 = findViewById(R.id.imageView1);
    Glide.with(MainActivity.
this)
    .load(
"url")
    .into(
imageView1);

   
imageView2 = findViewById(R.id.imageView2);
    RequestOptions cropOptions =
new RequestOptions();
    Glide.with(
this)
            .load(
"url")
            .apply(cropOptions.circleCrop())
            .into(
imageView2);
 
//   imageView3 = findViewById(R.id.imageView3);
}

댓글