Android 앱개발 공부/TIL(Today I Learned)

[Android] TIL 41일차

bunny code 2024. 7. 23. 21:47

프로젝트 진행(담당은 Dialog), 오늘은 먼저 Dialog layout 기본 구성부터 진행하였음

 

* AddContactDialog 출력 화면

맨 위에 빈 칸은 이미지가 들어가는 부분

 

* AddContactDialog 코드

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:background="@drawable/img_dialog_2">

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

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="1000dp">

            <ImageView
                android:id="@+id/iv_add_contact_image"
                android:layout_width="300dp"
                android:layout_height="300dp"
                android:layout_marginTop="30dp"
                android:background="@drawable/shape_corner_radius_30dp_bg"
                android:src="@drawable/img_sweetie_1"
                android:scaleType="fitXY"
                android:clipToOutline="true"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toEndOf="parent"/>

            <androidx.constraintlayout.widget.ConstraintLayout
                android:id="@+id/cl_add_contact_name"
                android:layout_width="300dp"
                android:layout_height="80dp"
                android:layout_marginTop="20dp"
                android:background="@drawable/shape_corner_radius_15dp_bg_primary_transparent"
                app:layout_constraintStart_toStartOf="@id/iv_add_contact_image"
                app:layout_constraintTop_toBottomOf="@id/iv_add_contact_image">
                <TextView
                    android:id="@+id/tv_add_contact_name"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/common_name"
                    android:textSize="16dp"
                    android:textColor="@color/black"
                    android:fontFamily="@font/yeonaesidae_r"
                    android:paddingTop="12dp"
                    android:paddingStart="20dp"
                    app:layout_constraintTop_toTopOf="@id/cl_add_contact_name"
                    app:layout_constraintStart_toStartOf="@id/cl_add_contact_name"/>
                <EditText
                    android:id="@+id/et_add_contact_name"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/dialog_placeholder_name"
                    android:textColor="@color/white"
                    android:textColorHint="@color/white"
                    android:textSize="24dp"
                    android:inputType="text"
                    android:fontFamily="@font/yeonaesidae_b"
                    android:paddingTop="8dp"
                    android:paddingStart="20dp"
                    android:paddingEnd="20dp"
                    android:background="@android:color/transparent"
                    app:layout_constraintTop_toBottomOf="@id/tv_add_contact_name"
                    app:layout_constraintStart_toStartOf="@id/tv_add_contact_name"/>
            </androidx.constraintlayout.widget.ConstraintLayout>

            <TextView
                android:layout_width="50dp"
                android:layout_height="18dp"
                android:text="@string/dialog_main_phone_number"
                android:textSize="10dp"
                android:textStyle="bold"
                android:fontFamily="@font/yeonaesidae_b"
                android:drawableStart="@drawable/ic_check"
                android:paddingTop="4dp"
                android:background="@drawable/shape_corner_radius_12dp_bg"
                app:layout_constraintTop_toBottomOf="@id/cl_add_contact_name"
                app:layout_constraintBottom_toTopOf="@id/cl_add_contact_phone_number"
                app:layout_constraintEnd_toEndOf="@id/cl_add_contact_name"/>

            <androidx.constraintlayout.widget.ConstraintLayout
                android:id="@+id/cl_add_contact_phone_number"
                android:layout_width="300dp"
                android:layout_height="80dp"
                android:layout_marginTop="40dp"
                android:background="@drawable/shape_corner_radius_15dp_bg_primary_transparent"
                app:layout_constraintStart_toStartOf="@id/cl_add_contact_name"
                app:layout_constraintTop_toBottomOf="@id/cl_add_contact_name">
                <TextView
                    android:id="@+id/tv_add_contact_phone_number"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/common_phone_number"
                    android:textSize="16dp"
                    android:textColor="@color/black"
                    android:fontFamily="@font/yeonaesidae_r"
                    android:paddingTop="12dp"
                    android:paddingStart="20dp"
                    app:layout_constraintTop_toTopOf="@id/cl_add_contact_phone_number"
                    app:layout_constraintStart_toStartOf="@id/cl_add_contact_phone_number"/>

                <EditText
                    android:id="@+id/et_add_contact_phone_number"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/dialog_placeholder_phone_number"
                    android:textColorHint="@color/white"
                    android:textColor="@color/white"
                    android:textSize="24dp"
                    android:inputType="phone"
                    android:fontFamily="@font/yeonaesidae_b"
                    android:paddingTop="8dp"
                    android:paddingStart="20dp"
                    android:paddingEnd="20dp"
                    android:background="@android:color/transparent"
                    app:layout_constraintTop_toBottomOf="@id/tv_add_contact_phone_number"
                    app:layout_constraintStart_toStartOf="@id/tv_add_contact_phone_number"/>
            </androidx.constraintlayout.widget.ConstraintLayout>

            <TextView
                android:id="@+id/tv_add_contact_add_phone_number"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:text="@string/dialog_add_phone_number"
                android:textSize="12dp"
                android:textColor="@color/primary"
                android:fontFamily="@font/yeonaesidae_b"
                app:layout_constraintStart_toStartOf="@id/cl_add_contact_phone_number"
                app:layout_constraintTop_toBottomOf="@id/cl_add_contact_phone_number"
                app:layout_constraintBottom_toTopOf="@id/cl_add_contact_event_information"/>

            <androidx.constraintlayout.widget.ConstraintLayout
                android:id="@+id/cl_add_contact_event_information"
                android:layout_width="300dp"
                android:layout_height="80dp"
                android:layout_marginTop="40dp"
                android:background="@drawable/shape_corner_radius_15dp_bg_primary_transparent"
                app:layout_constraintStart_toStartOf="@id/cl_add_contact_phone_number"
                app:layout_constraintTop_toBottomOf="@id/cl_add_contact_phone_number">
                <TextView
                    android:id="@+id/tv_add_contact_event_information"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/common_event_information"
                    android:textSize="16dp"
                    android:textColor="@color/black"
                    android:fontFamily="@font/yeonaesidae_r"
                    android:paddingTop="12dp"
                    android:paddingStart="20dp"
                    app:layout_constraintTop_toTopOf="@id/cl_add_contact_event_information"
                    app:layout_constraintStart_toStartOf="@id/cl_add_contact_event_information"/>

                <EditText
                    android:id="@+id/et_add_contact_event_information"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/dialog_placeholder_event_information"
                    android:textColor="@color/white"
                    android:textColorHint="@color/white"
                    android:textSize="24dp"
                    android:inputType="text"
                    android:fontFamily="@font/yeonaesidae_b"
                    android:paddingTop="8dp"
                    android:paddingStart="20dp"
                    android:paddingEnd="20dp"
                    android:background="@android:color/transparent"
                    app:layout_constraintTop_toBottomOf="@id/tv_add_contact_event_information"
                    app:layout_constraintStart_toStartOf="@id/tv_add_contact_event_information" />
            </androidx.constraintlayout.widget.ConstraintLayout>

            <androidx.constraintlayout.widget.ConstraintLayout
                android:id="@+id/cl_add_contact_relationship"
                android:layout_width="300dp"
                android:layout_height="80dp"
                android:layout_marginTop="20dp"
                android:background="@drawable/shape_corner_radius_15dp_bg_primary_transparent"
                app:layout_constraintStart_toStartOf="@id/cl_add_contact_event_information"
                app:layout_constraintTop_toBottomOf="@id/cl_add_contact_event_information">
                <TextView
                    android:id="@+id/tv_add_contact_relationship"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/common_relationship"
                    android:textSize="16dp"
                    android:textColor="@color/black"
                    android:fontFamily="@font/yeonaesidae_r"
                    android:paddingTop="12dp"
                    android:paddingStart="20dp"
                    app:layout_constraintTop_toTopOf="@id/cl_add_contact_relationship"
                    app:layout_constraintStart_toStartOf="@id/cl_add_contact_relationship"/>

                <EditText
                    android:id="@+id/et_add_contact_relationship"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/dialog_placeholder_relationship"
                    android:textColor="@color/white"
                    android:textColorHint="@color/white"
                    android:textSize="24dp"
                    android:inputType="text"
                    android:fontFamily="@font/yeonaesidae_b"
                    android:paddingTop="8dp"
                    android:paddingStart="20dp"
                    android:paddingEnd="20dp"
                    android:background="@android:color/transparent"
                    app:layout_constraintTop_toBottomOf="@id/tv_add_contact_relationship"
                    app:layout_constraintStart_toStartOf="@id/tv_add_contact_relationship"/>
            </androidx.constraintlayout.widget.ConstraintLayout>

            <androidx.constraintlayout.widget.ConstraintLayout
                android:id="@+id/cl_add_contact_group"
                android:layout_width="300dp"
                android:layout_height="80dp"
                android:layout_marginTop="20dp"
                android:background="@drawable/shape_corner_radius_15dp_bg_primary_transparent"
                app:layout_constraintStart_toStartOf="@id/cl_add_contact_relationship"
                app:layout_constraintTop_toBottomOf="@id/cl_add_contact_relationship">
                <TextView
                    android:id="@+id/tv_add_contact_group"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/common_group"
                    android:textSize="16dp"
                    android:textColor="@color/black"
                    android:fontFamily="@font/yeonaesidae_r"
                    android:paddingTop="12dp"
                    android:paddingStart="20dp"
                    app:layout_constraintTop_toTopOf="@id/cl_add_contact_group"
                    app:layout_constraintStart_toStartOf="@id/cl_add_contact_group"/>

                <EditText
                    android:id="@+id/et_add_contact_group"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/dialog_placeholder_group"
                    android:textColor="@color/white"
                    android:textColorHint="@color/white"
                    android:textSize="24dp"
                    android:inputType="text"
                    android:fontFamily="@font/yeonaesidae_b"
                    android:paddingTop="8dp"
                    android:paddingStart="20dp"
                    android:paddingEnd="20dp"
                    android:background="@android:color/transparent"
                    app:layout_constraintTop_toBottomOf="@id/tv_add_contact_group"
                    app:layout_constraintStart_toStartOf="@id/tv_add_contact_group"/>
            </androidx.constraintlayout.widget.ConstraintLayout>

            <androidx.constraintlayout.widget.ConstraintLayout
                android:id="@+id/cl_add_contact_memo"
                android:layout_width="300dp"
                android:layout_height="80dp"
                android:layout_marginTop="20dp"
                android:background="@drawable/shape_corner_radius_15dp_bg_primary_transparent"
                app:layout_constraintStart_toStartOf="@id/cl_add_contact_group"
                app:layout_constraintTop_toBottomOf="@id/cl_add_contact_group">
                <TextView
                    android:id="@+id/tv_add_contact_memo"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/common_memo"
                    android:textSize="16dp"
                    android:textColor="@color/black"
                    android:fontFamily="@font/yeonaesidae_r"
                    android:paddingTop="12dp"
                    android:paddingStart="20dp"
                    app:layout_constraintTop_toTopOf="@id/cl_add_contact_memo"
                    app:layout_constraintStart_toStartOf="@id/cl_add_contact_memo"/>

                <EditText
                    android:id="@+id/et_add_contact_memo"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/dialog_placeholder_memo"
                    android:textColor="@color/white"
                    android:textColorHint="@color/white"
                    android:textSize="24dp"
                    android:fontFamily="@font/yeonaesidae_b"
                    android:inputType="text"
                    android:paddingTop="8dp"
                    android:paddingStart="20dp"
                    android:paddingEnd="20dp"
                    android:background="@android:color/transparent"
                    app:layout_constraintTop_toBottomOf="@id/tv_add_contact_memo"
                    app:layout_constraintStart_toStartOf="@id/tv_add_contact_memo"/>
            </androidx.constraintlayout.widget.ConstraintLayout>
            
            <android.widget.Button
                android:id="@+id/btn_add_contact_cancel"
                android:text="@string/common_cancel"
                android:textColor="@color/white"
                android:textSize="20dp"
                android:fontFamily="@font/yeonaesidae_b"
                android:layout_width="125dp"
                android:layout_height="50dp"
                android:layout_marginTop="20dp"
                android:paddingTop="5dp"
                android:background="@drawable/img_btn"
                app:layout_constraintTop_toBottomOf="@id/cl_add_contact_memo"
                app:layout_constraintStart_toStartOf="@id/cl_add_contact_memo"/>

            <android.widget.Button
                android:id="@+id/btn_add_contact_save"
                android:text="@string/common_save"
                android:textColor="@color/white"
                android:textSize="20dp"
                android:fontFamily="@font/yeonaesidae_b"
                android:layout_width="125dp"
                android:layout_height="50dp"
                android:paddingTop="5dp"
                android:background="@drawable/img_btn"
                app:layout_constraintTop_toTopOf="@id/btn_add_contact_cancel"
                app:layout_constraintEnd_toEndOf="@id/cl_add_contact_memo"/>
        </androidx.constraintlayout.widget.ConstraintLayout>
    </ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>

 

 

* RandomCallDialog 출력 화면

 

 

 

* RandomCallDialog 코드

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="400dp"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <ImageView
        android:id="@+id/iv_random_call_image"
        android:src="@drawable/img_sweetie_2"
        android:scaleType="fitXY"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/cl_random_call_layout"
        android:layout_width="match_parent"
        android:layout_height="150dp"
        android:background="@drawable/img_dialog_1"
        android:layout_marginStart="6dp"
        android:layout_marginEnd="6dp"
        android:paddingStart="16dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintBottom_toBottomOf="parent">
        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/cl_random_call_name"
            android:layout_width="200dp"
            android:layout_height="50dp"
            android:background="@drawable/shape_corner_radius_15dp_bg_white"
            app:layout_constraintTop_toTopOf="@id/cl_random_call_layout"
            app:layout_constraintStart_toStartOf="@id/cl_random_call_layout">
        <TextView
            android:id="@+id/tv_random_call_name"
            android:text="@string/common_name"
            android:textColor="@color/primary"
            android:textSize="24dp"
            android:fontFamily="@font/yeonaesidae_b"
            android:padding="10dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:layout_constraintTop_toTopOf="@id/cl_random_call_name"
            app:layout_constraintBottom_toBottomOf="@id/cl_random_call_name"
            app:layout_constraintStart_toStartOf="@id/cl_random_call_name"/>

            <TextView
                android:id="@+id/tv_random_call_heart"
                android:text="호감도"
                android:textColor="@color/primary"
                android:textSize="24dp"
                android:fontFamily="@font/yeonaesidae_b"
                android:padding="10dp"
                android:paddingEnd="20dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:layout_constraintTop_toTopOf="@id/cl_random_call_name"
                app:layout_constraintBottom_toBottomOf="@id/cl_random_call_name"
                app:layout_constraintEnd_toEndOf="@id/cl_random_call_name"/>
        </androidx.constraintlayout.widget.ConstraintLayout>
        
        <TextView
            android:id="@+id/tv_random_call_question"
            android:text="[ 이름 ] 에게 전화를 거시겠습니까?"
            android:textColor="@color/black"
            android:textSize="20dp"
            android:fontFamily="@font/yeonaesidae_b"
            android:paddingTop="6dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:layout_constraintTop_toBottomOf="@id/cl_random_call_name"
            app:layout_constraintStart_toStartOf="@id/cl_random_call_name"/>

        <TextView
            android:id="@+id/tv_random_call_make_a_call"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/dialog_make_a_call"
            android:textSize="18dp"
            android:textColor="@color/primary"
            android:fontFamily="@font/yeonaesidae_b"
            app:layout_constraintTop_toBottomOf="@id/tv_random_call_question"
            app:layout_constraintStart_toStartOf="@id/tv_random_call_question"/>

        <TextView
            android:id="@+id/tv_random_call_make_a_call_cancel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/dialog_make_a_call_cancel"
            android:textSize="18dp"
            android:textColor="@color/gray"
            android:fontFamily="@font/yeonaesidae_b"
            app:layout_constraintTop_toBottomOf="@id/tv_random_call_make_a_call"
            app:layout_constraintStart_toStartOf="@id/tv_random_call_make_a_call"/>
    </androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

 

 

* EditTextDialog, ThemeDialog 출력 화면

 

 

* EditTextDialog 코드

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="300dp"
    android:layout_height="180dp"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:background="@drawable/img_dialog_1">

    <TextView
        android:id="@+id/tv_edit_name"
        android:text="@string/dialog_edit_name"
        android:textColor="@color/white"
        android:fontFamily="@font/yeonaesidae_b"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="18dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"/>

    <EditText
        android:id="@+id/et_edit_name"
        android:layout_width="230dp"
        android:layout_height="wrap_content"
        android:hint="@string/common_phone_number"
        android:textSize="15dp"
        android:fontFamily="@font/yeonaesidae_r"
        android:background="@drawable/shape_corner_radius_15dp_bg_tertiary"
        android:layout_marginTop="10dp"
        android:padding="15dp"
        app:layout_constraintTop_toBottomOf="@id/tv_edit_name"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        />

    <android.widget.Button
        android:id="@+id/btn_edit_save"
        android:text="@string/common_save"
        android:textColor="@color/white"
        android:textSize="15dp"
        android:fontFamily="@font/yeonaesidae_b"
        android:layout_width="90dp"
        android:layout_height="33dp"
        android:layout_marginBottom="15dp"
        android:layout_marginEnd="30dp"
        android:paddingTop="5dp"
        android:background="@drawable/img_btn"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>

 

* ThemeDialog 코드

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="300dp"
    android:layout_height="120dp"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:background="@drawable/img_dialog_1">

    <TextView
        android:id="@+id/tv_theme_change_text"
        android:text="@string/dialog_change_theme"
        android:textColor="@color/white"
        android:fontFamily="@font/yeonaesidae_b"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="18dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"/>

    <android.widget.Button
        android:id="@+id/btn_theme_change_cancel"
        android:text="@string/common_cancel"
        android:textColor="@color/white"
        android:textSize="15dp"
        android:fontFamily="@font/yeonaesidae_b"
        android:layout_width="90dp"
        android:layout_height="33dp"
        android:layout_marginStart="30dp"
        android:layout_marginBottom="15dp"
        android:paddingTop="5dp"
        android:background="@drawable/img_btn"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"/>

    <android.widget.Button
        android:id="@+id/btn_theme_change_save"
        android:text="@string/common_save"
        android:textColor="@color/white"
        android:textSize="15dp"
        android:fontFamily="@font/yeonaesidae_b"
        android:layout_width="90dp"
        android:layout_height="33dp"
        android:layout_marginStart="50dp"
        android:layout_marginBottom="15dp"
        android:paddingTop="5dp"
        android:background="@drawable/img_btn"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toEndOf="@id/btn_theme_change_cancel"/>


</androidx.constraintlayout.widget.ConstraintLayout>

'Android 앱개발 공부 > TIL(Today I Learned)' 카테고리의 다른 글

[Android] TIL 43일차  (0) 2024.07.31
[Android] TIL 42일차  (0) 2024.07.31
[Android] TIL 40일차  (3) 2024.07.22
[Android] TIL 38일차  (1) 2024.07.18
[Android] TIL 37일차  (0) 2024.07.16