fix(home): 최근 데뷔 카드 clipping을 보완한다

This commit is contained in:
2026-06-29 16:41:32 +09:00
parent 93a5d1293c
commit 08c7bcf4f2
3 changed files with 31 additions and 16 deletions

View File

@@ -1,8 +1,10 @@
package kr.co.vividnext.sodalive.v2.main.home.ui package kr.co.vividnext.sodalive.v2.main.home.ui
import android.graphics.Outline
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.ViewOutlineProvider
import android.widget.ImageView import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
@@ -22,7 +24,7 @@ class HomeRecentDebutCreatorAdapter(
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CreatorViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CreatorViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_home_recent_debut_creator, parent, false) val view = LayoutInflater.from(parent.context).inflate(R.layout.item_home_recent_debut_creator, parent, false)
view.layoutParams = recentDebutItemLayoutParams(parent) view.layoutParams = view.layoutParams.recentDebutItemLayoutParams(parent)
return CreatorViewHolder(view, onClickItem) return CreatorViewHolder(view, onClickItem)
} }
@@ -39,6 +41,16 @@ class HomeRecentDebutCreatorAdapter(
private val profileImage = itemView.findViewById<ImageView>(R.id.iv_home_recent_debut_creator_profile) private val profileImage = itemView.findViewById<ImageView>(R.id.iv_home_recent_debut_creator_profile)
private val nicknameText = itemView.findViewById<TextView>(R.id.tv_home_recent_debut_creator_nickname) private val nicknameText = itemView.findViewById<TextView>(R.id.tv_home_recent_debut_creator_nickname)
init {
itemView.clipToOutline = true
itemView.outlineProvider = object : ViewOutlineProvider() {
override fun getOutline(view: View, outline: Outline) {
val radius = view.resources.getDimension(R.dimen.radius_14)
outline.setRoundRect(0, 0, view.width, view.height, radius)
}
}
}
fun bind(item: HomeRecommendationCreatorUiModel) { fun bind(item: HomeRecommendationCreatorUiModel) {
profileImage.loadUrl(item.profileImage) profileImage.loadUrl(item.profileImage)
nicknameText.text = item.nickname nicknameText.text = item.nickname
@@ -46,10 +58,9 @@ class HomeRecentDebutCreatorAdapter(
} }
} }
private fun recentDebutItemLayoutParams(parent: ViewGroup): RecyclerView.LayoutParams { private fun ViewGroup.LayoutParams.recentDebutItemLayoutParams(parent: ViewGroup): RecyclerView.LayoutParams {
return RecyclerView.LayoutParams( return RecyclerView.LayoutParams(this).apply {
ViewGroup.LayoutParams.WRAP_CONTENT, marginEnd = parent.resources.getDimensionPixelSize(R.dimen.spacing_4)
ViewGroup.LayoutParams.WRAP_CONTENT }
).apply { marginEnd = parent.resources.getDimensionPixelSize(R.dimen.spacing_4) }
} }
} }

View File

@@ -1,15 +1,14 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="205dp" android:layout_width="185dp"
android:layout_height="259dp" android:layout_height="234dp"
android:background="@drawable/bg_home_recent_debut_card" android:background="@drawable/bg_home_recent_debut_card">
android:outlineProvider="background">
<ImageView <ImageView
android:id="@+id/iv_home_recent_debut_creator_profile" android:id="@+id/iv_home_recent_debut_creator_profile"
android:layout_width="205dp" android:layout_width="match_parent"
android:layout_height="259dp" android:layout_height="match_parent"
android:contentDescription="@null" android:contentDescription="@null"
android:scaleType="centerCrop" android:scaleType="centerCrop"
tools:src="@drawable/ic_launcher_background" /> tools:src="@drawable/ic_launcher_background" />

View File

@@ -229,10 +229,11 @@ class HomeMainFragmentLayoutTest {
val profileImage = recentDebut.findViewById<ImageView>(R.id.iv_home_recent_debut_creator_profile) val profileImage = recentDebut.findViewById<ImageView>(R.id.iv_home_recent_debut_creator_profile)
val nicknameText = recentDebut.findViewById<TextView>(R.id.tv_home_recent_debut_creator_nickname) val nicknameText = recentDebut.findViewById<TextView>(R.id.tv_home_recent_debut_creator_nickname)
assertEquals(205.dpToPx(), recentDebut.layoutParams.width) assertEquals(185.dpToPx(), recentDebut.layoutParams.width)
assertEquals(259.dpToPx(), recentDebut.layoutParams.height) assertEquals(234.dpToPx(), recentDebut.layoutParams.height)
assertEquals(205.dpToPx(), profileImage.layoutParams.width) assertEquals(R.drawable.bg_home_recent_debut_card, shadowOf(recentDebut.background).createdFromResId)
assertEquals(259.dpToPx(), profileImage.layoutParams.height) assertEquals(ViewGroup.LayoutParams.MATCH_PARENT, profileImage.layoutParams.width)
assertEquals(ViewGroup.LayoutParams.MATCH_PARENT, profileImage.layoutParams.height)
assertEquals(24f, nicknameText.textSize / nicknameText.resources.displayMetrics.scaledDensity) assertEquals(24f, nicknameText.textSize / nicknameText.resources.displayMetrics.scaledDensity)
assertEquals(Gravity.CENTER, nicknameText.gravity) assertEquals(Gravity.CENTER, nicknameText.gravity)
} }
@@ -248,7 +249,11 @@ class HomeMainFragmentLayoutTest {
val layoutParams = viewHolder.itemView.layoutParams as ViewGroup.MarginLayoutParams val layoutParams = viewHolder.itemView.layoutParams as ViewGroup.MarginLayoutParams
assertEquals(14.dpToPx(), recentDebutList.paddingStart) assertEquals(14.dpToPx(), recentDebutList.paddingStart)
assertEquals(185.dpToPx(), layoutParams.width)
assertEquals(234.dpToPx(), layoutParams.height)
assertEquals(4.dpToPx(), layoutParams.marginEnd) assertEquals(4.dpToPx(), layoutParams.marginEnd)
assertTrue(viewHolder.itemView.clipToOutline)
assertNotNull(viewHolder.itemView.outlineProvider)
} }
@Test @Test