fix(character): 인기 캐릭터

- TextView 숫자 하단 여백(descent) 제거
This commit is contained in:
2025-09-11 20:04:13 +09:00
parent f830c98b8e
commit 88d13ce77a
2 changed files with 31 additions and 22 deletions

View File

@@ -4,6 +4,7 @@ import android.annotation.SuppressLint
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.ViewTreeObserver
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import coil.load import coil.load
import coil.transform.RoundedCornersTransformation import coil.transform.RoundedCornersTransformation
@@ -27,13 +28,27 @@ class CharacterAdapter(
// 순위 표시 여부 결정 // 순위 표시 여부 결정
if (showRanking) { if (showRanking) {
binding.llRanking.visibility = View.VISIBLE binding.tvRanking.visibility = View.VISIBLE
binding.tvRanking.text = (index + 1).toString() binding.tvRanking.text = (index + 1).toString()
binding.tvRanking.apply {
includeFontPadding = false
maxLines = 1
// 뷰가 측정된 뒤 메트릭이 확정되므로, preDraw 시점에 보정
viewTreeObserver.addOnPreDrawListener(
object : ViewTreeObserver.OnPreDrawListener {
override fun onPreDraw(): Boolean {
viewTreeObserver.removeOnPreDrawListener(this)
val fm = paint.fontMetrics
// 글리프 하단을 라인 박스 하단에 맞추기 위한 시프트
translationY = fm.descent
return true
}
})
}
} else { } else {
binding.llRanking.visibility = View.GONE binding.tvRanking.visibility = View.GONE
} }
binding.ivCharacter.clipToOutline = true
binding.ivCharacter.load(character.imageUrl) { binding.ivCharacter.load(character.imageUrl) {
crossfade(true) crossfade(true)
placeholder(R.drawable.ic_logo_service_center) placeholder(R.drawable.ic_logo_service_center)

View File

@@ -1,39 +1,33 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="168dp" android:layout_width="168dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<FrameLayout <FrameLayout
android:layout_width="168dp" android:layout_width="168dp"
android:layout_height="wrap_content"> android:layout_height="168dp"
android:background="@color/black">
<ImageView <ImageView
android:id="@+id/iv_character" android:id="@+id/iv_character"
android:layout_width="168dp" android:layout_width="match_parent"
android:layout_height="168dp" android:layout_height="match_parent"
android:contentDescription="@null" android:contentDescription="@null"
android:scaleType="centerCrop" /> android:scaleType="centerCrop" />
<!-- 순위 표시 (인기 캐릭터에서만 보임) --> <TextView
<LinearLayout android:id="@+id/tv_ranking"
android:id="@+id/ll_ranking"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:layout_marginStart="14dp" android:fontFamily="@font/pretendard_bold"
android:gravity="center" android:includeFontPadding="false"
android:orientation="horizontal" android:maxLines="1"
android:visibility="gone"> android:textColor="@color/white"
android:textSize="72sp"
<TextView tools:text="1" />
android:id="@+id/tv_ranking"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/pretendard_bold"
android:textColor="@color/white"
android:textSize="72sp" />
</LinearLayout>
</FrameLayout> </FrameLayout>
<LinearLayout <LinearLayout