개발/Rising Camp Android 4th

[1주차/피드백] 레이아웃 클론 코딩 (추가 과제)

Eun 2022. 2. 12. 21:57

1주차 피드백

  • 전체적으로 조사가 미흡함 (palette, layout..)
  • Layout 활용을 다 하지 못함

1주차 추가 과제

  • 인스타 레이아웃 클론 코딩 

완성화면

레이아웃 구조

코드

<?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"
    android:orientation="vertical"
    android:background="@color/black">
    <LinearLayout
        android:id="@+id/ll_status_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        android:orientation="horizontal">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:layout_marginLeft="20dp"
            android:text="11:58"
            android:textStyle="bold"
            android:textColor="@color/white"/>

        <View
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_weight="1"/>

        <ImageView
            android:layout_width="80dp"
            android:layout_height="30dp"
            android:src="@drawable/appbar_battery"
            android:layout_marginRight="20dp"
            android:layout_gravity="right"/>
    </LinearLayout>
    <LinearLayout
        android:id="@+id/ll_logo_dm_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="10dp"
        android:gravity="center_vertical"
        app:layout_constraintTop_toBottomOf="@+id/ll_status_bar"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent">
        <ImageView
            android:layout_width="130dp"
            android:layout_height="50dp"
            android:src="@drawable/instargram_logo"/>
        <View
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_weight="1"/>

        <ImageView
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_gravity="right"
            android:src="@drawable/plus"/>
        <ImageView
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_gravity="right"
            android:src="@drawable/heart"/>
        <ImageView
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_gravity="right"
            android:src="@drawable/dm"/>
    </LinearLayout>
    <LinearLayout
        android:id="@+id/ll_my_story"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="10dp"
        android:orientation="vertical"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/ll_logo_dm_bar">
        <FrameLayout
            android:layout_width="60dp"
            android:layout_height="60dp">
            <View
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/story_oval"/>
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:scaleType="fitXY"
                android:src="@drawable/story_person_noze"/>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="right">
                <ImageView
                    android:layout_width="20dp"
                    android:layout_height="20dp"
                    android:layout_gravity="bottom"
                    android:src="@drawable/story_plus"/>
            </LinearLayout>
        </FrameLayout>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="내 스토리"
            android:layout_gravity="center"
            android:textSize="10dp"
            android:textColor="@color/white"/>
    </LinearLayout>
    <HorizontalScrollView
        android:id="@+id/hscroll_story_list"
        app:layout_constraintTop_toBottomOf="@+id/ll_logo_dm_bar"
        app:layout_constraintLeft_toRightOf="@+id/ll_my_story"
        android:layout_marginTop="10dp"
        android:layout_width="0dp"
        android:layout_height="wrap_content">
        <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:orientation="horizontal">
                <LinearLayout
                    android:layout_width="60dp"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">
                    <FrameLayout
                        android:layout_width="match_parent"
                        android:layout_height="60dp"
                        android:background="@drawable/story_oval">
                    <androidx.cardview.widget.CardView
                        android:layout_width="50dp"
                        android:layout_height="50dp"
                        android:layout_gravity="center"
                        app:cardCornerRadius="300dp">
                        <ImageView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:scaleType="fitXY"
                            android:src="@drawable/img_story_selfi"/>
                    </androidx.cardview.widget.CardView>
                    </FrameLayout>
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="nozeworld"
                        android:textSize="10dp"
                        android:layout_gravity="center"
                        android:textColor="@color/white"/>
                </LinearLayout>

            <LinearLayout
                android:layout_width="60dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:orientation="vertical">
                <FrameLayout
                    android:layout_width="match_parent"
                    android:layout_height="60dp"
                    android:background="@drawable/story_on_oval">
                    <androidx.cardview.widget.CardView
                        android:layout_width="50dp"
                        android:layout_height="50dp"
                        android:layout_gravity="center"
                        app:cardCornerRadius="300dp">
                        <ImageView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:scaleType="fitXY"
                            android:src="@drawable/img_story_selfi"/>
                    </androidx.cardview.widget.CardView>
                </FrameLayout>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="nozeworld"
                    android:textSize="10dp"
                    android:layout_gravity="center"
                    android:textColor="@color/white"/>
            </LinearLayout>
            </LinearLayout>

    </HorizontalScrollView>
    <View
        android:id="@+id/view_story_boundary"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_marginTop="10dp"
        app:layout_constraintTop_toBottomOf="@id/hscroll_story_list"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        android:background="#100F0F"/>
    <LinearLayout
        android:id="@+id/ll_feed_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginLeft="10dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/view_story_boundary">

        <androidx.cardview.widget.CardView
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_gravity="center_vertical"
            app:cardCornerRadius="300dp">
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:scaleType="fitXY"
                android:src="@drawable/feed_profile_picture"/>
        </androidx.cardview.widget.CardView>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_gravity="center_vertical"
            android:textStyle="bold"
            android:textColor="@color/white"
            android:text="1amny"/>
        <View
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_weight="1"/>
        <ImageView
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_marginRight="10dp"
            android:src="@drawable/feed_etc"/>
    </LinearLayout>
    <FrameLayout
        android:id="@+id/fl_feed_picture"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        app:layout_constraintTop_toBottomOf="@+id/ll_feed_bar">
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/feed_picture"
            android:scaleType="fitXY"
            android:adjustViewBounds="true"/>
        <ImageView
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:src="@drawable/tag"
            android:layout_margin="5dp"
            android:layout_gravity="bottom"
            android:adjustViewBounds="true"
            android:scaleType="fitXY"/>
        <ImageView
            android:layout_width="150dp"
            android:layout_height="50dp"
            android:layout_marginLeft="10dp"
            android:src="@drawable/tag_message"
            android:adjustViewBounds="true" />
        <ImageView
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="5dp"
            android:src="@drawable/picture_count"
            android:layout_gravity="right"
            android:adjustViewBounds="true" />
    </FrameLayout>
    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottom_navi"
        app:menu="@menu/bottom_navi"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:itemIconSize="30dp"
        android:background="@color/black"
        app:labelVisibilityMode="unlabeled"
        app:itemIconTint="@color/white"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@id/fl_feed_picture">
    </com.google.android.material.bottomnavigation.BottomNavigationView>

</androidx.constraintlayout.widget.ConstraintLayout>

 

어려웠던 점

  • 인스타 스토리에서 볼 수 있는 그라데이션 테두리, 회색 테두리를 어떻게 구현할 지 헤맸음
  • 내 스토리에서 볼 수 있는 플러스 이미지(오른쪽 하단밑)와 내 이미지의 중첩을 위해서 프레임레이아웃안에 내 프로필 이미지를 넣고 리니어레이아웃안에 플러스 버튼 이미지를 넣었다. 여기에 위에서 언급한 회색 테두리를 넣어야 했다..
  • bottomNavigationView에서 클릭했을 때 색 변하게 하는 것을 조금 헤맸다. 인스타 블랙모드로 하면 밑에바도 블랙이기때문에 background를 black을 주고 아래 코드를 넣었더니 아이콘이 하얀색으로 바뀌면서 보였다.
    app:itemIconTint="@color/white"​
     itemIconTint는 이미지의 색상 변화이고, itemTextColor는 글자의 색상 변화이다.