티스토리 뷰
build.gradle (Module: app)
dependencies {
// Glide
implementation 'com.github.bumptech.glide:glide:4.11.0'
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
tools:context=".MainActivity" >
<ImageView
android:id="@+id/ivpicture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="30dp"
/>
</LinearLayout>
MainActivity.kt
package com.jwsoft.kotlinproject
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.bumptech.glide.Glide
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
Glide.with(this).load("http://goo.gl/gEgYUd").into(ivpicture)
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jwsoft.kotlinproject">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:usesCleartextTraffic="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
<uses-permission android:name="android.permission.INTERNET" /> 추가
android:usesCleartextTraffic="true" 추가
MainActivity.kt
package com.jwsoft.kotlinproject
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.bumptech.glide.Glide
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
Glide.with(this).load("http://goo.gl/gEgYUd").override(200, 200).into(ivpicture)
}
}
MainActivity.kt
package com.jwsoft.kotlinproject
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.bumptech.glide.Glide
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
Glide.with(this)
.load("http://goo.gl/gEgYUd")
.placeholder(R.drawable.ic_launcher_foreground)
.into(ivpicture)
}
}
MainActivity.kt
package com.jwsoft.kotlinproject
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.bumptech.glide.Glide
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
Glide.with(this)
.load("http://?????????")
.error(R.drawable.ic_launcher_background)
.into(ivpicture)
}
}
MainActivity.kt
package com.jwsoft.kotlinproject
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.bumptech.glide.Glide
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
Glide.with(this)
.asGif()
.load("http://i.imgur.com/1ALnB2s.gif")
.placeholder(R.drawable.ic_launcher_foreground)
.into(ivpicture)
}
}
'Android > Kotlin' 카테고리의 다른 글
[Kotlin] StickyHeader + RecyclerView (0) | 2020.08.14 |
---|---|
[Kotlin] @JvmOverloads (0) | 2020.08.12 |
[Kotlin] NestedScrollView (0) | 2020.08.10 |
[Kotlin] ProgressBar (0) | 2020.08.07 |
[Kotlin] viewModelScope + ViewModel (0) | 2020.08.07 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- recyclerview
- MVVM
- 혀가 길지 않은 개발자
- Livedata
- JSONArray
- CoordinatorLayout
- java
- DataBinding
- Architecture Pattern
- 자바
- XML
- TabLayout
- View
- 안드로이드 #코틀린 #Android #Kotlin
- Kotlin
- ViewPager2
- 안드로이드
- activity
- ArrayList
- ViewModel
- handler
- coroutine
- 코틀린
- fragment
- Android
- Intent
- Vue.js #Vue.js + javascript
- Design Pattern
- JSONObject
- James Kim
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
글 보관함