마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

프레임레이아웃이 자꾸만 상, 하에 있는 앱바들을 복제해냅니다.

0 추천

프레임레이아웃이 화면의 상, 하에 있는 앱바들을 사진처럼 찍어내어, 리사이클러뷰의 아이템 항목에

 

넣어서 아이템들과 함께 출력시켜줍니다.

 

쉽게 말해서, 한 화면안에 있는 모든 출력물들을 사진 찍듯이 리사이클러뷰 항목 1개에

 

이 화면을 그대로 찍어넣어서 출력시켜줍니다.

 

리사이클러뷰 항목 갯수가 140개인데, 화면을 140개 복제하여, 항목에 들어가는 아이템과 함께 출력됩니다.

 

스크롤을 시작하면, 140개의 아주 긴~~~ 화면이 출력됩니다... 뷰홀더 클래스나 어댑터를 잘못 설정한게 아닙니다.

 

오로지 태그에서 잘못된것 같습니다.

 

<LinearLayout 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"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    android:orientation="vertical"
    tools:context="com.example.yhw.TestActivity"
    tools:showIn="@layout/activity_test">

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:id="@+id/coordinator1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true">

        <com.google.android.material.appbar.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="?actionBarSize"
            android:background="@color/white">

            <LinearLayout
                android:id="@+id/linear1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_scrollFlags="scroll|enterAlways"
                android:orientation="horizontal">

                <TextView
                    android:id="@+id/download"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_marginTop="3dp"
                    android:layout_gravity="center"
                    android:layout_weight="1"
                    android:drawableTop="@drawable/drawable_download"
                    android:text="다운"
                    android:textSize="14dp"
                    android:gravity="center"/>

                <TextView
                    android:id="@+id/title2"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:text="예레미야3장27절"
                    android:textSize="25dp"
                    android:gravity="center"
                    android:layout_weight="3" />

                <TextView
                    android:id="@+id/menu"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_marginTop="4dp"
                    android:drawableTop="@drawable/drawable_menu"
                    android:layout_weight="1"
                    android:text="메뉴"
                    android:textSize="14dp"
                    android:gravity="center"/>

            </LinearLayout>

        </com.google.android.material.appbar.AppBarLayout>

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="#f0f0f0"/>

        <!-- width와 hieght를 match로 해줘야 리사이클러뷰가 스크롤 가능해진다. -->
        <FrameLayout
            android:id="@+id/fragmentBorC"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true">

            <TextView
                android:id="@+id/IntText"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                tools:text="This is some temp text" />

        </FrameLayout>
        <!-- layout_weight는 사용하면 안된다. 상하단바 스크롤 기능이 사라진다. -->
        <!-- ★리사이클러뷰의 내용물을 상단바 바로 밑에서부터 시작되게 코딩해놓자.★ -->

        <com.google.android.material.bottomnavigation.BottomNavigationView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            app:layout_behavior="com.google.android.material.behavior.HideBottomViewOnScrollBehavior">


                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal">

                    <TextView
                        android:id="@+id/reduce2"
                        android:layout_width="match_parent"
                        android:layout_height="52dp"
                        android:layout_marginTop="3dp"
                        android:layout_weight="1"
                        android:drawableTop="@drawable/drawable_reduce"
                        android:gravity="bottom|center"
                        android:text="축소"
                        android:textSize="14dp" />
                    <!-- 이거는 화면을 전환시키자. 그래서 선택된 절들을 저장시키고, 답을 찾았을때 연결시키자 -->

                    <TextView
                        android:id="@+id/search2"
                        android:layout_width="match_parent"
                        android:layout_height="52dp"
                        android:layout_marginTop="3dp"
                        android:layout_weight="1"
                        android:drawableTop="@drawable/drawable_search"
                        android:gravity="bottom|center"
                        android:text="검색"
                        android:textSize="14dp" />

                    <TextView
                        android:id="@+id/reading2"
                        android:layout_width="match_parent"
                        android:layout_height="52dp"
                        android:layout_marginTop="3dp"
                        android:layout_weight="1"
                        android:drawableTop="@drawable/drawable_reading"
                        android:gravity="bottom|center"
                        android:text="말씀"
                        android:textSize="14dp" />

                    <TextView
                        android:id="@+id/home2"
                        android:layout_width="match_parent"
                        android:layout_height="52dp"
                        android:layout_marginTop="3dp"
                        android:layout_weight="1"
                        android:clickable="true"
                        android:drawableTop="@drawable/drawable_home"
                        android:gravity="bottom|center"
                        android:text="집"
                        android:textSize="14dp" />

                    <TextView
                        android:id="@+id/question2"
                        android:layout_width="match_parent"
                        android:layout_height="52dp"
                        android:layout_marginTop="3dp"
                        android:layout_weight="1"
                        android:clickable="true"
                        android:drawableTop="@drawable/drawable_question"
                        android:gravity="bottom|center"
                        android:text="질문"
                        android:textSize="14dp" />

                </LinearLayout>
        </com.google.android.material.bottomnavigation.BottomNavigationView>
    </androidx.coordinatorlayout.widget.CoordinatorLayout>
</LinearLayout>

 

상쾌한 (1,890 포인트) 님이 2021년 1월 4일 질문

1개의 답변

+1 추천
 
채택된 답변

증상만 보면, activity_test를
adapter의 onCreateViewHolder에서 매칭한 것 같네요.

RecyclerView에 메인 화면이 중첩되어서 나타난다면,
어댑터에서 layout 지정을 제대로 했는지 부터 확인해야 합니다.

어댑터의 layout은 item에 대한 layout이 지정되어야 합니다.
크로스 체크 해 보시기 바랍니다.

Will Kim (43,170 포인트) 님이 2021년 1월 4일 답변
상쾌한님이 2021년 1월 4일 채택됨
아마 답변해주신게 맞지 않을까 싶은데요... 와~ 해결됐습니다. 정말 감사합니다. 이거 며칠전부터 계속 해결 못하고 있었던건데, 어디서도 이걸 답해주는 곳이 없더라구요. 감사하고 또 감사합니다.
네.. 참고로 개발할 때는 문제를 예측하지 마세요.

질문자께서 아래와 같이 문제를 예단했죠...

뷰홀더 클래스나 어댑터를 잘못 설정한게 아닙니다.
오로지 태그에서 잘못된것 같습니다.

그 예단으로 인해서 어댑터 설정 쪽을 스스로 안보게 만든 것입니다.

오류가 나거나 이상 행동을 하게 되면,
그 오류로 검색을 하거나, 이상 행동에 대한 원인에 대해서 모든 가능성을 열어 두고 접근해야 정말 훌륭한 문제 해결자가 됩니다.
바로 증거로 부터 출발해야 하는 것이죠.

Follow the evidence - 길 그리섬, CSI 라스베가스.
좋은 말씀 해주셔서 감사합니다. 모르는 것을 함부로 판단하는 것이 옳지 않았음에도 까맣게 잊고, 어느새 이런 생각을 하고 있었네요...
...