Kotlin/TIL

TIL (02.26)

내손은개발 🐾 2024. 2. 26. 22:32
팀 / 팀원 소개 프로젝트 제작

 

오늘 한 일

 

1. splash 띄우기

 

1-1) app 수준의 build.gradle에서 implementation

implementation("androidx.core:core-splashscreen:1.0.1")

 

1-2) themes.xml 추가

    <style name="Theme.AppCompat.SplashScreen" parent="Theme.SplashScreen">
        <item name="windowSplashScreenBackground">@color/white</item>
        <item name="windowSplashScreenAnimatedIcon">@drawable/icon_i</item>
        <item name="postSplashScreenTheme">@style/Base.Theme.Kotlin_ot_project_I</item>

    </style>

 

1-3) manifests 수정

        <activity
            android:name=".MainActivity"
            android:theme="@style/Theme.AppCompat.SplashScreen" //수정
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

 

1-4) mainActivity.kt

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import com.example.kotlin_ot_project_i.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity() {
    private lateinit var binding: ActivityMainBinding
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityMainBinding.inflate(layoutInflater)
        Thread.sleep(1000)
        installSplashScreen()
        setContentView(binding.root)
        
    }
}

 

 

2. RecyclerView

사용해본적이 없어서 찾아봐야한다.

먼저 xml에 RecyclerView를 추가한뒤

            <androidx.recyclerview.widget.RecyclerView
                android:layout_marginTop="20dp"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginStart="30dp"
                android:layout_marginEnd="30dp"/>

 

recyclerView_item.xml을 만들어줬다. 

더보기

<?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="180dp">


<ImageView
android:id="@+id/personImageView"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_marginStart="10dp"
android:src="@drawable/icon_person_man"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/nameTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
app:layout_constraintStart_toEndOf="@id/personImageView"
app:layout_constraintTop_toTopOf="@id/personImageView"
tools:text="이름" />

<TextView
android:id="@+id/birthdayTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
app:layout_constraintStart_toEndOf="@id/personImageView"
app:layout_constraintTop_toBottomOf="@id/nameTextView"
tools:text="생년월일" />

<TextView
android:id="@+id/mbtiTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
app:layout_constraintStart_toEndOf="@id/personImageView"
app:layout_constraintTop_toBottomOf="@id/birthdayTextView"
tools:text="MBTI" />

</androidx.constraintlayout.widget.ConstraintLayout>

임시로 제작한 내용

 

다음으로 ViewHolder를 받아야하는데 막혀있다,,

dummy data로 생성한 다음에 해봐야 그나마 편할 것 같다.

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

TIL (02.28)  (0) 2024.02.28
TIL (02.27)  (1) 2024.02.27
TIL (02.23)  (0) 2024.02.23
TIL (02.21)  (0) 2024.02.21
TIL (02.20)  (0) 2024.02.20