Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detail 화면에서 성능 향상을 위해 해야하는 것. #2

Open
8954sood opened this issue Jan 16, 2024 · 0 comments
Open

Detail 화면에서 성능 향상을 위해 해야하는 것. #2

8954sood opened this issue Jan 16, 2024 · 0 comments

Comments

@8954sood
Copy link
Member

8954sood commented Jan 16, 2024

<?xml version="1.0" encoding="utf-8"?>
<layout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <data>
        <variable
            name="vm"
            type="com.b1nd.alimo.feature.detail.DetailViewModel"/>
    </data>
    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <ImageView
            android:id="@+id/image_back_button"
            android:layout_width="28dp"
            android:layout_height="28dp"
            android:layout_marginTop="10dp"
            android:layout_marginStart="16dp"
            android:src="@drawable/ic_back_arrow"
            android:background="@drawable/ripple_white"
            android:clickable="true"
            android:focusable="true"
            android:onClick="@{() -> vm.onClickBack()}"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintStart_toStartOf="parent"/>
        <androidx.coordinatorlayout.widget.CoordinatorLayout
            android:id="@+id/layout_coordinator"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:background="@color/Gray300"
            app:layout_constraintTop_toBottomOf="@id/image_back_button"
            app:layout_constraintBottom_toTopOf="@id/layout_bottom">
            <com.google.android.material.appbar.AppBarLayout
                android:id="@+id/appbar_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_behavior=".custom.CustomAppBarLayoutBehavior">
                <com.google.android.material.appbar.CollapsingToolbarLayout
                    android:id="@+id/layout_collapsing"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    app:contentScrim="@color/white"
                    app:statusBarScrim="@color/white"
                    app:layout_scrollFlags="scroll|exitUntilCollapsed">
                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">
                        <androidx.constraintlayout.widget.ConstraintLayout
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            app:layout_collapseMode="parallax">
                            <ImageView
                                android:id="@+id/image_profile"
                                android:layout_width="36dp"
                                android:layout_height="36dp"
                                android:layout_marginStart="12dp"
                                android:layout_marginTop="26dp"
                                android:src="@drawable/ic_red_badge"
                                app:layout_constraintTop_toTopOf="parent"
                                app:layout_constraintStart_toStartOf="parent"/>
                            <LinearLayout
                                android:id="@+id/layout_profile"
                                android:layout_width="0dp"
                                android:layout_height="wrap_content"
                                android:layout_marginStart="8dp"
                                android:layout_marginEnd="12dp"
                                android:layout_marginTop="25dp"
                                app:layout_constraintTop_toTopOf="parent"
                                app:layout_constraintStart_toEndOf="@id/image_profile"
                                app:layout_constraintEnd_toEndOf="parent">
                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:text="테스트"
                                    android:textSize="12sp"
                                    android:textFontWeight="700"
                                    android:textColor="@color/Gray700"/>
                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_marginStart="4dp"
                                    android:layout_marginTop="1dp"
                                    android:text="2023년 1월 33일 오후 25:3"
                                    android:textSize="10sp"
                                    android:textFontWeight="500"
                                    android:textColor="@color/Gray500"/>
                            </LinearLayout>
                            <TextView
                                android:id="@+id/text_content"
                                android:layout_width="0dp"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="16dp"
                                android:text="너 좀 수상함... 아니 그게 아니라 수상함...문화상품권 \n받으러오셈."
                                android:textFontWeight="500"
                                android:textColor="@color/Main900"
                                app:layout_constraintTop_toBottomOf="@id/image_profile"
                                app:layout_constraintStart_toStartOf="@id/image_profile"
                                app:layout_constraintEnd_toEndOf="@id/layout_profile"/>

                            <ImageView
                                android:id="@+id/image_content"
                                android:layout_width="0dp"
                                android:layout_height="0dp"
                                android:layout_marginTop="12dp"
                                android:background="@drawable/shape_image_view"
                                android:scaleType="centerCrop"
                                android:src="@drawable/ic_launcher_background"
                                android:clipToOutline="true"
                                app:layout_constraintDimensionRatio="320:326"
                                app:layout_constraintTop_toBottomOf="@id/text_content"
                                app:layout_constraintStart_toStartOf="@id/text_content"
                                app:layout_constraintEnd_toEndOf="@id/layout_profile"/>

                            <LinearLayout
                                android:id="@+id/layout_emoji"
                                android:layout_width="0dp"
                                android:layout_height="36dp"
                                android:layout_marginTop="12dp"
                                android:background="@drawable/shape_gray100_4"
                                app:layout_constraintTop_toBottomOf="@id/image_content"
                                app:layout_constraintStart_toStartOf="@id/text_content"
                                app:layout_constraintEnd_toEndOf="@id/layout_profile">
                                <LinearLayout
                                    android:layout_width="match_parent"
                                    android:layout_height="match_parent"
                                    android:layout_marginHorizontal="43dp"
                                    android:gravity="center_vertical">
                                    <ImageView
                                        android:id="@+id/image_okay"
                                        style="@style/imae_emoji"
                                        android:src="@drawable/ic_okay" />
                                    <androidx.appcompat.widget.LinearLayoutCompat
                                        android:layout_width="0dp"
                                        android:layout_height="0dp"
                                        android:layout_weight="1"/>
                                    <ImageView
                                        android:id="@+id/image_love"
                                        android:src="@drawable/ic_love"
                                        style="@style/imae_emoji" />
                                    <androidx.appcompat.widget.LinearLayoutCompat
                                        android:layout_width="0dp"
                                        android:layout_height="0dp"
                                        android:layout_weight="1"/>
                                    <ImageView
                                        android:id="@+id/image_laugh"
                                        style="@style/imae_emoji"
                                        android:src="@drawable/ic_laugh" />
                                    <androidx.appcompat.widget.LinearLayoutCompat
                                        android:layout_width="0dp"
                                        android:layout_height="0dp"
                                        android:layout_weight="1"/>
                                    <ImageView
                                        android:id="@+id/image_sad"
                                        style="@style/imae_emoji"
                                        android:src="@drawable/ic_sad" />
                                    <androidx.appcompat.widget.LinearLayoutCompat
                                        android:layout_width="0dp"
                                        android:layout_height="0dp"
                                        android:layout_weight="1"/>
                                    <ImageView
                                        android:id="@+id/image_angry"
                                        style="@style/imae_emoji"
                                        android:src="@drawable/ic_angry" />
                                </LinearLayout>
                            </LinearLayout>

                            <com.google.android.material.divider.MaterialDivider
                                android:id="@+id/divider_line"
                                android:layout_width="match_parent"
                                android:layout_height="0.5dp"
                                android:layout_marginTop="14dp"
                                app:dividerColor="@color/Gray300"
                                app:layout_constraintTop_toBottomOf="@id/layout_emoji"/>

                        </androidx.constraintlayout.widget.ConstraintLayout>
                    </RelativeLayout>
                    <androidx.appcompat.widget.Toolbar
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:background="@color/white"
                        app:layout_collapseMode="pin"/>
                </com.google.android.material.appbar.CollapsingToolbarLayout>
            </com.google.android.material.appbar.AppBarLayout>
            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/rv_comment"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/white"
                android:nestedScrollingEnabled="false"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"
                app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
        </androidx.coordinatorlayout.widget.CoordinatorLayout>
        <LinearLayout
            android:id="@+id/layout_bottom"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            app:layout_constraintBottom_toBottomOf="parent">
            <com.google.android.material.divider.MaterialDivider
                android:id="@+id/divider_text_line"
                android:layout_width="match_parent"
                android:layout_height="1dp"
                app:dividerColor="@color/Gray300"
                app:layout_constraintBottom_toTopOf="@id/layout_text_field"/>

            <androidx.constraintlayout.widget.ConstraintLayout
                android:id="@+id/layout_text_field"
                android:layout_width="match_parent"
                android:layout_height="48dp"
                android:orientation="horizontal"
                app:layout_constraintBottom_toBottomOf="parent">
                <EditText
                    android:id="@+id/edit_send"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_marginStart="16dp"
                    android:background="@null"
                    android:hint="댓글을 남겨보세요."
                    android:textSize="12sp"
                    android:textFontWeight="500"
                    android:fontFamily="@font/pretendard"
                    app:layout_constraintTop_toTopOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintEnd_toStartOf="@id/layout_send"/>
                <LinearLayout
                    android:id="@+id/layout_send"
                    android:layout_width="48dp"
                    android:layout_height="48dp"
                    android:gravity="center"
                    android:clickable="true"
                    android:focusable="true"
                    android:background="@drawable/ripple_white"
                    android:onClick="@{() -> vm.onClickSend()}"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintTop_toTopOf="parent">
                    <ImageView
                        android:layout_width="22dp"
                        android:layout_height="22dp"
                        android:src="@drawable/ic_send" />
                </LinearLayout>
            </androidx.constraintlayout.widget.ConstraintLayout>
        </LinearLayout>
    </androidx.constraintlayout.widget.ConstraintLayout>
</layout>

와 같은 구조를 시도했지만, CoordinatorLayout가 이상한 여백을 가지고 있습니다. 이를 위해서
3중 리사이클러뷰 구조를 제안합니다.
ConstraintLayout

  • Topbar
  • Rv
  • BottomBar

rv의 크기는 topbar와 bottombar 크기에 유동적.

그후 rv는 두개의 아이템을 가집니다.

  • postView
  • commentRv

또 commentRv는 아이템으로

  • commentView(commentcommentRv)를 가집니다.

commentcommentRv는 아이템으로

  • commentcommentView를 가집니다.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant