Conversation
kimdoyeon1234
left a comment
There was a problem hiding this comment.
1주차 미션 완료하시느라 정말 수고 많으셨습니다! 😃 클릭했을 때 다른 텍스트 색상이 원래대로 돌아오는 단일 선택 로직 짜주신 점이 너무 좋았고, 벡터 이미지 이름들도 ic로 맞춰주신거 너무 좋았습니다!
다만 커밋을 하실때에는 대문자가 아닌 소문자로 커밋태그를 달아주세요!
코드 전반적으로 훌륭하게 동작하지만, 더 완성도 높은 안드로이드 프로젝트를 위해 몇 가지 개선하면 좋을 부분들을 리뷰로 남겼습니다. 또한 pr을 올리실때에는 동작 영상 또는 실행화면을 캡쳐해서 내용을 다 채워주시기 바랍니다!
마지막으로 사진같은 요소들을 올리실때에는 마크다운(Markdown)을 활용하면 훨씬 보기 좋게 작성할 수 있습니다!
ex) 파이프 기호(|)로 칸을 나누고 하이픈(---)으로 두 번째 줄을 구분해 주는 방식
나중에 pr제출하실때 사진이 많다면은 표로 정리해서 올려주세요!
| val btnBack = findViewById<ImageButton>(R.id.btnBack) | ||
|
|
||
| val itemHappy = findViewById<LinearLayout>(R.id.itemHappy) | ||
| val itemExcited = findViewById<LinearLayout>(R.id.itemExcited) | ||
| val itemNormal = findViewById<LinearLayout>(R.id.itemNormal) | ||
| val itemAnxious = findViewById<LinearLayout>(R.id.itemAnxious) | ||
| val itemAngry = findViewById<LinearLayout>(R.id.itemAngry) | ||
|
|
||
| textHappy = findViewById(R.id.textHappy) | ||
| textExcited = findViewById(R.id.textExcited) | ||
| textNormal = findViewById(R.id.textNormal) | ||
| textAnxious = findViewById(R.id.textAnxious) | ||
| textAngry = findViewById(R.id.textAngry) |
There was a problem hiding this comment.
MainActivity를 보면 findViewById가 10번이나 반복되고 있습니다. 요즘 안드로이드 개발에서는 뷰 바인딩(View Binding)을 도입해서 이런 보일러플레이트 코드를 줄이고 Null 안정성을 챙기는 추세입니다! 다음 미션 때 꼭 한번 적용해 보시는 걸 추천해요!
| itemHappy.setOnClickListener { | ||
| resetTextColor() | ||
| textHappy.setTextColor(Color.parseColor("#FF9800")) | ||
| showEmotion("행복") | ||
| } |
There was a problem hiding this comment.
Color.parseColor("#FF9800") 같은 값들이 하드코딩되어 있습니다
이런 값들을 colors.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" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="match_parent" | ||
| android:background="#F3F3F3"> | ||
|
|
||
| <ImageButton | ||
| android:id="@+id/btnBack" | ||
| android:layout_width="24dp" | ||
| android:layout_height="24dp" | ||
| android:layout_marginStart="20dp" | ||
| android:layout_marginTop="20dp" | ||
| android:background="@android:color/transparent" | ||
| android:src="@android:drawable/ic_media_previous" | ||
| app:layout_constraintStart_toStartOf="parent" | ||
| app:layout_constraintTop_toTopOf="parent" /> | ||
|
|
||
| <ScrollView | ||
| android:layout_width="0dp" | ||
| android:layout_height="0dp" | ||
| android:fillViewport="true" | ||
| app:layout_constraintTop_toBottomOf="@id/btnBack" | ||
| app:layout_constraintBottom_toBottomOf="parent" | ||
| app:layout_constraintStart_toStartOf="parent" | ||
| app:layout_constraintEnd_toEndOf="parent"> | ||
|
|
||
| <LinearLayout | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" | ||
| android:orientation="vertical" | ||
| android:gravity="center_horizontal" | ||
| android:paddingStart="24dp" | ||
| android:paddingEnd="24dp" | ||
| android:paddingTop="24dp" | ||
| android:paddingBottom="40dp"> | ||
|
|
||
| <TextView | ||
| android:id="@+id/textView" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:text="오늘 하루는 어땠나요?" | ||
| android:textColor="@color/black" | ||
| android:textSize="30sp" | ||
| android:textStyle="bold" | ||
| android:gravity="center" | ||
| android:textAlignment="center" /> | ||
|
|
||
| <TextView | ||
| android:id="@+id/textView2" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginTop="10dp" | ||
| android:text="감정우표를 선택해주세요" | ||
| android:textColor="@color/black" | ||
| android:textSize="20sp" | ||
| android:gravity="center" | ||
| android:textAlignment="center" /> | ||
|
|
||
| <TextView | ||
| android:id="@+id/textView3" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginTop="24dp" | ||
| android:text="선택한 감정우표를 기반으로 맞춤형 질문이 배달됩니다" | ||
| android:textColor="#666666" | ||
| android:textSize="12sp" | ||
| android:gravity="center" | ||
| android:textAlignment="center" /> | ||
|
|
||
| <LinearLayout | ||
| android:id="@+id/itemHappy" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginTop="36dp" | ||
| android:orientation="vertical" | ||
| android:gravity="center" | ||
| android:clickable="true" | ||
| android:focusable="true"> | ||
|
|
||
| <ImageView | ||
| android:layout_width="64dp" | ||
| android:layout_height="64dp" | ||
| android:src="@drawable/ic_emotion_happy" /> | ||
|
|
||
| <TextView | ||
| android:id="@+id/textHappy" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginTop="8dp" | ||
| android:text="더없이 행복한 하루였어요" | ||
| android:textColor="@color/black" | ||
| android:textSize="18sp" /> | ||
| </LinearLayout> | ||
|
|
||
| <LinearLayout | ||
| android:id="@+id/itemExcited" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginTop="28dp" | ||
| android:orientation="vertical" | ||
| android:gravity="center" | ||
| android:clickable="true" | ||
| android:focusable="true"> | ||
|
|
||
| <ImageView | ||
| android:layout_width="64dp" | ||
| android:layout_height="64dp" | ||
| android:src="@drawable/ic_emotion_excited" /> | ||
|
|
||
| <TextView | ||
| android:id="@+id/textExcited" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginTop="8dp" | ||
| android:text="들뜨고 흥분돼요" | ||
| android:textColor="@color/black" | ||
| android:textSize="18sp" /> | ||
| </LinearLayout> | ||
|
|
||
| <LinearLayout | ||
| android:id="@+id/itemNormal" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginTop="28dp" | ||
| android:orientation="vertical" | ||
| android:gravity="center" | ||
| android:clickable="true" | ||
| android:focusable="true"> | ||
|
|
||
| <ImageView | ||
| android:layout_width="64dp" | ||
| android:layout_height="64dp" | ||
| android:src="@drawable/ic_emotion_normal" /> | ||
|
|
||
| <TextView | ||
| android:id="@+id/textNormal" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginTop="8dp" | ||
| android:text="평범한 하루였어요" | ||
| android:textColor="@color/black" | ||
| android:textSize="18sp" /> | ||
| </LinearLayout> | ||
|
|
||
| <LinearLayout | ||
| android:id="@+id/itemAnxious" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginTop="28dp" | ||
| android:orientation="vertical" | ||
| android:gravity="center" | ||
| android:clickable="true" | ||
| android:focusable="true"> | ||
|
|
||
| <ImageView | ||
| android:layout_width="64dp" | ||
| android:layout_height="64dp" | ||
| android:src="@drawable/ic_emotion_anxious" /> | ||
|
|
||
| <TextView | ||
| android:id="@+id/textAnxious" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginTop="8dp" | ||
| android:text="생각이 많아지고 불안해요" | ||
| android:textColor="@color/black" | ||
| android:textSize="18sp" /> | ||
| </LinearLayout> | ||
|
|
||
| <LinearLayout | ||
| android:id="@+id/itemAngry" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginTop="28dp" | ||
| android:orientation="vertical" | ||
| android:gravity="center" | ||
| android:clickable="true" | ||
| android:focusable="true"> | ||
|
|
||
| <ImageView | ||
| android:layout_width="64dp" | ||
| android:layout_height="64dp" | ||
| android:src="@drawable/ic_emotion_angry" /> | ||
|
|
||
| <TextView | ||
| android:id="@+id/textAngry" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginTop="8dp" | ||
| android:text="부글부글 화가 나요" | ||
| android:textColor="@color/black" | ||
| android:textSize="18sp" /> | ||
| </LinearLayout> | ||
|
|
||
| </LinearLayout> | ||
| </ScrollView> | ||
|
|
||
| </androidx.constraintlayout.widget.ConstraintLayout> No newline at end of file |
There was a problem hiding this comment.
전반적인 디자인은 잘 구현해 주셨어요! 다만 이번 주차가 ConstraintLayout 주차인 만큼, 중첩된 LinearLayout들을 지우고 뷰들을 서로 제약(Constraint)을 걸어 평평하게 배치해 중앙정렬하는게 좋을거 같습니다!
| android:id="@+id/textView" | ||
| android:layout_width="wrap_content" |
There was a problem hiding this comment.
현재 xml의 아이디가 textView1, 2 처럼 되어 있습니다. 나중에 뷰가 많아지면 textView1이 어떤 감정이었는지 헷갈릴 수 있어요!
대신 tv_happy (TextView + 감정), good 대신 iv_good (ImageView + 감정)처럼 어떤 뷰인지, 어떤 역할인지 알 수 있게 접두어를 붙여서 이름을 지어주시면 코드를 읽기 훨씬 편해집니다! 다음 미션부터는 꼭 참고해주세요!
| android:layout_marginTop="10dp" | ||
| android:text="감정우표를 선택해주세요" | ||
| android:textColor="@color/black" | ||
| android:textSize="20sp" |
There was a problem hiding this comment.
이런 값들을 res/values/strings.xml과 colors.xml로 분리해 두면, 나중에 텍스트나 색상을 변경해야 할 때 코드를 일일이 찾아다니며 바꿀 필요 없이 해당 xml 파일 한 곳에서만 싹 수정하면 되기 때문에 훨씬 편리해집니다!
| private fun showEmotion(emotion: String) { | ||
| Toast.makeText(this, "선택한 감정: $emotion", Toast.LENGTH_SHORT).show() | ||
| } |
There was a problem hiding this comment.
Toast가 있으면 확실히 시각적으로 더 좋아 보일 것 같네요. 굿 아이디어
| android:text="들뜨고 흥분돼요" | ||
| android:textColor="@color/black" |
There was a problem hiding this comment.
텍스트랑 컬러 따로 분리하셔서 관리하면 유지보수에 좋을 거 같아요!! ui 모두 잘 구현하셨네요! 수고 많으셨습니다 !!
| @@ -0,0 +1,24 @@ | |||
| package com.example.myapplication | |||
📌 PR 제목
feat: 1주차 미션 - layout을 이용해 단일 화면 구성하기
🔗 관련 이슈
Closes #이슈번호
✨ 변경 사항
🔍 테스트
📸 스크린샷 (선택)
🚨 추가 이슈