티스토리 뷰

Android/Kotlin

[Kotlin]  ProgressBar

혀가 길지 않은 개발자 2020. 8. 7. 18:42

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    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:gravity="center"
    tools:context=".MainActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:orientation="vertical">

        <Button
            android:id="@+id/btnVisible"
            android:layout_width="match_parent"
            android:layout_height="70dp"
            android:layout_gravity="center"
            android:textAllCaps="false"
            android:text="Visible"
            android:textSize="26dp"
            android:textStyle="italic" />

        <Button
            android:id="@+id/btnGone"
            android:layout_width="match_parent"
            android:layout_height="70dp"
            android:layout_gravity="center"
            android:textAllCaps="false"
            android:text="Gone"
            android:textSize="26dp"
            android:textStyle="italic" />

    </LinearLayout>

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ProgressBar
            android:id="@+id/pbLoading"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center" />

    </FrameLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

activity_main.xml

 

 

 

 

 

MainActivity.kt

package com.jwsoft.kotlinproject

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        btnVisible.setOnClickListener {
            pbLoading.visibility = View.VISIBLE
        }

        btnGone.setOnClickListener {
            pbLoading.visibility = View.INVISIBLE
        }
    }

}

실행 결과

 

 

 

 

 

'Android > Kotlin' 카테고리의 다른 글

[Kotlin]  Glide  (0) 2020.08.10
[Kotlin]  NestedScrollView  (0) 2020.08.10
[Kotlin]  viewModelScope  +  ViewModel  (0) 2020.08.07
[Kotlin]  by lazy  (0) 2020.08.07
[Kotlin]  BuildConfig  (0) 2020.08.07
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
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
글 보관함