반응형
<ImageView
android:id="@+id/previewImg"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="55dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="20dp"
android:adjustViewBounds="true"
android:scaleType="centerInside" />
- height를 코틀린에서 wrap_content로 변경해 봅니다.
- adjustViewBounds는 이미지뷰를 경계선에 따라 조정할지 여부입니다. background에 커스텀 레이아웃을 사용할 때 유용합니다.
val layoutParams = binding.previewImg.layoutParams
layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT
binding.previewImg.layoutParams = layoutParams
반응형