UI
전체 코드
MainActivity.kt
더보기
class MainActivity : AppCompatActivity() {
val binding by lazy { ActivityMainBinding.inflate(layoutInflater) }
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
}
fun onClick(v: View) {
when(v.id) {
R.id.button -> {
val intent = Intent(this, DialogActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity(intent)
}
}
}
}
DialogActivity.kt
더보기
class DialogActivity : AppCompatActivity() {
val binding by lazy { ActivityDialogBinding.inflate(layoutInflater) }
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
supportRequestWindowFeature(Window.FEATURE_NO_TITLE)
setContentView(binding.root)
}
}
activity_main.xml
더보기
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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"
tools:context=".MainActivity">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Intent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:onClick="onClick" />
</androidx.constraintlayout.widget.ConstraintLayout>
|
cs |
activity_dialog.xml
더보기
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
32
|
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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"
tools:context=".DialogActivity">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="300dp"
android:layout_height="300dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dialog Activity"
android:textSize="30sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
|
cs |
values/styles.xml
더보기
1
2
3
4
5
6
7
|
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="round_dialog_activity" parent="@style/Theme.AppCompat.DayNight.Dialog">
<item name="android:windowBackground">@drawable/bg_round_dialog</item>
<item name="android:windowBackgroundFallback">@color/white</item>
</style>
</resources>
|
cs |
drawable/bg_round_dialog.xml
더보기
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<corners android:radius="15dp" />
<solid android:color="#ffffff" />
<stroke
android:width="3dp"
android:color="#ffffff" />
<padding
android:bottom="6dp"
android:left="6dp"
android:right="6dp"
android:top="3dp" />
</shape>
|
cs |
AndroidManifest.xml
더보기
1
2
3
|
<activity android:name=".DialogActivity"
android:screenOrientation="portrait"
android:theme="@style/round_dialog_activity" />
|
cs |
'Android > Code' 카테고리의 다른 글
[Project] [Android] [Kotlin] Log Window (0) | 2021.10.18 |
---|---|
[Android] [Kotlin] Google Map (0) | 2021.09.24 |
[Android] [Kotlin] EditText 자동 포커싱 및 키보드 (0) | 2021.09.23 |
[Android] [Kotlin] chooser Intent (카메라, 갤러리) (0) | 2021.09.12 |
[Android] [Kotlin] 프래그먼트 사용 방법 및 구조 (0) | 2021.09.11 |