728x90
반응형
RecyclerView를 지정하여 item으로 내용을 보여주다 보면 내용이 잘려서 안보이는 경우가 있다.


첫번째 사진처럼 마지막의 내용이 링크로 끝나야하는데 두번째 사진처럼 내용이 안보이는 경우가 있다.
이러한 증상이 발생하는 이유는 상위의 레이아웃이 ConstraintLayout이면서 RecyclerView의 height을 "wrap_content"로 지정하는 경우에 발생한다.
height의 특정 값을 부여해주면 되지만 item 내용에 따라 height을 조절하고 싶기 때문에 다른 방법을 사용해야한다.
해결하는 방법은 다음과 같다.
item을 보여줄 RecyclerView에
app:layout_constrainedHeight="true"
app:layout_constrainedHeight="true" 를 추가하면 된다.
나의 경우 RecyclerView를 감싸고 있는 ScrollView가 있어 ScrollView와 RecyclerView에 둘다 넣어줬다. 아래처럼 말이다.
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:layout_marginTop="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.03"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/line"
app:layout_constraintVertical_bias="0.0"
app:layout_constrainedHeight="true"
android:scrollbars="none">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rankDetailRecyclerView"
android:layout_width="330dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.03"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/line"
app:layout_constraintVertical_bias="0.0"
app:layout_constrainedHeight="true" />
</ScrollView>
그러면

보여주고 싶은 모든 내용이 잘 보여지는걸 확인할 수 있다.
728x90
반응형
'안드로이드(Android)' 카테고리의 다른 글
| 특정 뷰에 애니메이션 적용하는 방법 그리고 적용 후 GONE 혹은 INVISIBLE이 안될 때 (0) | 2023.08.28 |
|---|---|
| ImageView나 특정 View에 그림자 커스텀하여 지정하는 방법 + 그림자를 지정하니 이미지의 사이즈가 이상해지는 경우 (0) | 2023.08.22 |
| 안드로이드의 fab 사이즈 조절하기(floatingButton 사이즈) (0) | 2023.08.11 |
| activity!!(느낌표2개) 대신 requireActivity를 사용하는 이유 (0) | 2023.04.12 |
| com.android.support 리팩토링하기(과거 라이브러리 리팩토링) (0) | 2023.04.08 |