리사이클러 뷰를 사용하여 영화 리스트를 출력하였다. 하지만 스크롤한 뒤 올라갔을때 이전 리스트들이 올라가 있는 경우가 있었다.
해결하기 위해 다른 곳을 찾아보니 여러원인 들과 해결 방법이 있었으나 나의 경우에는 xml을 잘못 만들었던 것이었다.
리사이클러뷰에 들어갈 요소인 item_search_poster의 xml에 습관적으로 ConstraintLayout을 자동으로 만들어 주는 infer Constraints 버튼을 눌렀었는데 이를 통해 ConstarintLayout이 생겼어서 그랬다.
따라서 Code상에서 맨위와 아래의
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
</androidx.constraintlayout.widget.ConstraintLayout>
을 삭제해준다.
<?xml version="1.0" encoding="utf-8"?>
<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_margin="5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/poster_image_view"
android:background="@drawable/poster_rounded_corner"
android:layout_width="120dp"
android:padding="5dp"
android:layout_height="200dp" />
</LinearLayout>
따라서 다음과 같이 리사이클러뷰에 들어갈 이미지 뷰를 설정해준다.
반응형
'Android Studio' 카테고리의 다른 글
리사이클러뷰(RecyclerView) 3개씩 정렬하여 출력하기 (0) | 2022.12.06 |
---|---|
리사이클러뷰(Recyclerview)를 사용하여 이미지 출력하기 (2) | 2022.12.05 |
프래그먼트(fragment)안에서 버튼 눌렀을 시 해당 프래그먼트 바꾸기 (0) | 2022.12.05 |
Volley Error 해결 - RequestQueue 오류, Context오류 (0) | 2022.11.20 |
안드로이드 스튜디오 api요청-TMDB api를 통하여 인기 영화 정보 받아오기(volley, gson) (0) | 2022.11.17 |