티스토리 뷰
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
android:background="#FFFFFF"
tools:context=".MainActivity">
<ImageView
android:id="@+id/ivProfile"
android:layout_width="200dp"
android:layout_height="200dp"
android:src="@drawable/iv_profile"/>
</LinearLayout>

MainActivity.kt
package com.jwsoft.kotlinproject
import android.graphics.drawable.ShapeDrawable
import android.graphics.drawable.shapes.OvalShape
import android.os.Build
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
ivProfile.background = ShapeDrawable(OvalShape())
if (Build.VERSION.SDK_INT >= 21) {
ivProfile.clipToOutline = true // 모양에 맞게 이미지 출력
}
}
}

'Android > Kotlin' 카테고리의 다른 글
| [Kotlin] Generics (2) (0) | 2020.08.06 |
|---|---|
| [Kotlin] Toolbar + include (0) | 2020.08.05 |
| [Kotlin] CoordinatorLayout + ViewPager2 + TabLayout (0) | 2020.08.03 |
| [Kotlin] Retrofit2 + Coroutine (1) | 2020.08.02 |
| [Kotlin] import com.google.gson.* (0) | 2020.07.31 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- View
- MVVM
- ViewModel
- Android
- recyclerview
- fragment
- Vue.js #Vue.js + javascript
- JSONArray
- Design Pattern
- java
- handler
- Intent
- Architecture Pattern
- James Kim
- activity
- 혀가 길지 않은 개발자
- 코틀린
- 자바
- ViewPager2
- 안드로이드 #코틀린 #Android #Kotlin
- Kotlin
- JSONObject
- Livedata
- 안드로이드
- CoordinatorLayout
- XML
- TabLayout
- DataBinding
- ArrayList
- coroutine
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
글 보관함