본문 바로가기

📱/📘Project

[Kotlin] Note 앱 만들기1

이번에 만들 Note 앱에서는 FragmentRoom을 써보려고 함.

 

▪️Fragment

https://heaven0713.tistory.com/58

 

[Kotlin] 프래그먼트(Fragment)

이번 솝트 세미나에서 중심적으로 다룬게 프래그먼트와 리사이클러뷰였다. 근데 (아쉽게도) 리사이클러뷰로 블로그에 글을 쓴 적이 있으므로 나중에 그 글을 수정하기로 마음먹고 한번도 작성

heaven0713.tistory.com

 

▪️Room

https://frtt0608.tistory.com/103

 

[AOS] ROOM이란?

Android에서 ROOM이란 무엇일까? ROOM은 데이터베이스의 데이터를 Java 또는 Kotlin 객체로 매핑해주는 ORM 라이브러리입니다. ORM(Object Relational Mapping)이란? 객체 지향 프로그래밍은 Class를 사용하고, 관

frtt0608.tistory.com

 

▪️만들며 참고하면 좋은 글(물론 내 글)

https://ta2gi.tistory.com/38

 

[Android Studio] 앱 만들기 전 알면 유용한 것들

▪️기본 배경 색상 설정 values → themes → themes.xml 에서 하단에 원하는 색상을 추가하면 기본 배경 색상으로 설정된다. ▪️글자 색 설정 values → colors.xml 에서 하단에 #FF9E9E9E을 추가하고 사용법

ta2gi.tistory.com

 

Activity와 Fragment를 구분하기 위해 패키지를 만들어서 넣어줬음. (본인 마음대로!)

패키지는 Java 하단의 자신의 패키지 → New → Package를 클릭해 이름을 지어주면 됨.

 

 

Fragment는 패키지에서 New → Fragment → Fragment(Blank)를 클릭해 만들면 됨.

만들고 보면 이상한 코드들이 있을 텐데 다 필요 없긴 한데 일단 내버려둠.

 

우선 각각의 UI 구성 먼저 끝냈음.

 

activity_main.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="match_parent"
    tools:context=".MainActivity">

    <FrameLayout
        android:id="@+id/mai_screen"
        android:layout_width="match_parent"
        android:layout_height="match_parent"

        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>

 

fragment_home.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"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context=".fragment.HomeFragment"
    android:background="#FF1D1D1D">

    <LinearLayout
        android:id="@+id/home_top"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:padding="5dp"

        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Note"
            android:textColor="@color/color_basic"
            android:textSize="17dp"
            android:fontFamily="@font/gothic_bold"/>

        <ImageView
            android:id="@+id/hom_add"
            android:layout_width="25dp"
            android:layout_height="match_parent"
            android:src="@drawable/icon_add"/>

    </LinearLayout>

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/hom_recyclerview"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:paddingHorizontal="5dp"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"

        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/home_top"
        app:layout_constraintBottom_toBottomOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>

 

fragment_add.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"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context=".fragment.AddFragment"
    android:background="#FF1D1D1D">

    <LinearLayout
        android:id="@+id/add_top"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:padding="5dp"

        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <ImageView
            android:id="@+id/add_cancel"
            android:layout_width="25dp"
            android:layout_height="match_parent"
            android:src="@drawable/icon_cancel"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Add Note"
            android:textColor="@color/color_basic"
            android:textSize="17dp"
            android:fontFamily="@font/gothic_bold"
            android:gravity="center"/>

        <ImageView
            android:id="@+id/add_complete"
            android:layout_width="25dp"
            android:layout_height="match_parent"
            android:src="@drawable/icon_complete"/>

    </LinearLayout>

    <EditText
        android:id="@+id/add_edittext"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:paddingHorizontal="10dp"
        android:paddingTop="10dp"
        android:hint="이 곳에 작성해주세요."
        android:textColorHint="@color/color_basic"
        android:textColor="@color/color_basic"
        android:textSize="16dp"
        android:fontFamily="@font/gothic_regular"
        android:textStyle="bold"
        android:gravity="start"
        android:inputType="textMultiLine"
        android:background="@null"

        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@id/add_top"
        app:layout_constraintBottom_toBottomOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>

 

fragment_detail.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"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context=".fragment.AddFragment"
    android:background="#FF1D1D1D">

    <LinearLayout
        android:id="@+id/det_top"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:padding="5dp"

        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <ImageView
            android:id="@+id/det_cancel"
            android:layout_width="25dp"
            android:layout_height="match_parent"
            android:src="@drawable/icon_cancel"/>

        <TextView
            android:id="@+id/det_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Note"
            android:textColor="@color/color_basic"
            android:textSize="17dp"
            android:fontFamily="@font/gothic_bold"
            android:gravity="center"/>

        <ImageView
            android:id="@+id/det_edit"
            android:layout_width="25dp"
            android:layout_height="match_parent"
            android:src="@drawable/icon_edit"/>

    </LinearLayout>

    <TextView
        android:id="@+id/det_text"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:paddingHorizontal="5dp"
        android:paddingTop="10dp"
        android:text="작성한 노트입니다."
        android:textColor="@color/color_basic"
        android:textSize="16dp"
        android:fontFamily="@font/gothic_regular"
        android:textStyle="bold"

        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@id/det_top"
        app:layout_constraintBottom_toBottomOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>

 

fragment_edit.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"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context=".fragment.AddFragment"
    android:background="#FF1D1D1D">

    <LinearLayout
        android:id="@+id/edi_top"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:padding="5dp"

        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <ImageView
            android:id="@+id/edi_cancel"
            android:layout_width="25dp"
            android:layout_height="match_parent"
            android:src="@drawable/icon_cancel"/>

        <TextView
            android:id="@+id/edi_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Edit Note"
            android:textColor="@color/color_basic"
            android:textSize="17dp"
            android:fontFamily="@font/gothic_bold"
            android:gravity="center"/>

        <ImageView
            android:id="@+id/edi_complete"
            android:layout_width="25dp"
            android:layout_height="match_parent"
            android:src="@drawable/icon_complete"/>

    </LinearLayout>

    <EditText
        android:id="@+id/edi_edittext"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:paddingHorizontal="10dp"
        android:paddingTop="10dp"
        android:hint="이 곳에 작성해주세요."
        android:textColorHint="@color/color_basic"
        android:textColor="@color/color_basic"
        android:textSize="16dp"
        android:fontFamily="@font/gothic_regular"
        android:textStyle="bold"
        android:gravity="start"
        android:inputType="textMultiLine"
        android:background="@null"

        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@id/edi_top"
        app:layout_constraintBottom_toBottomOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>

 

마지막으로 리사이클러뷰에 들어갈 항목의 UI.

 

list_item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    android:id="@+id/ite_layout"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/background_round"
    android:backgroundTint="#E53935"
    android:padding="5dp"
    android:layout_margin="5dp">

    <TextView
        android:id="@+id/ite_text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="작성한 노트 \n가나다라마 \nABCDEF \n123456789"
        android:textColor="@color/white"
        android:textSize="15dp"
        android:fontFamily="@font/gothic_regular"
        android:textStyle="bold"
        android:maxLines="5"
        android:paddingHorizontal="5dp"
        android:paddingVertical="15dp"/>

</LinearLayout>

 

To be Continued..🧐

'📱 > 📘Project' 카테고리의 다른 글

[Kotlin] Note 앱 만들기3  (1) 2023.01.11
[Kotlin] Note 앱 만들기2  (0) 2023.01.10
[Kotlin] TodoList 앱 만들기3  (0) 2023.01.03
[Kotlin] TodoList 앱 만들기2  (2) 2022.12.29
[Kotlin] TodoList 앱 만들기1  (0) 2022.12.29