Sfoglia il codice sorgente

feat: UserIdView间距调整

pengwuliang 6 mesi fa
parent
commit
82c300e3dd

+ 9 - 11
app/src/main/java/com/adealink/weparty/module/profile/view/UserIdView.kt

@@ -35,9 +35,7 @@ class UserIdView @JvmOverloads constructor(
 
     private var copyBtnResID = R.drawable.profile_sid_bg
 
-    private var copyBtnSize = 12
-
-    private var copyBtnMarginStart = 6
+    private var copyBtnSize = 14.dp()
 
     //常规字体颜色
     private var normalTextColor = Color.parseColor("#FFFFFF")
@@ -59,9 +57,7 @@ class UserIdView @JvmOverloads constructor(
             val ta = context.obtainStyledAttributes(it, R.styleable.UserIdView)
             showCopyBtn = ta.getBoolean(R.styleable.UserIdView_show_copy_btn, false)
             copyBtnResID = ta.getResourceId(R.styleable.UserIdView_copy_btn_res_id, R.drawable.profile_copy_ic)
-            copyBtnSize = ta.getDimensionPixelSize(R.styleable.UserIdView_copy_btn_size, 16.dp())
-            copyBtnMarginStart = ta.getDimensionPixelSize(R.styleable.UserIdView_copy_btn_margin_start, 4.dp())
-
+            copyBtnSize = ta.getDimensionPixelSize(R.styleable.UserIdView_copy_btn_size, 14.dp())
             normalTextColor = ta.getColor(
                 R.styleable.UserIdView_id_text_color,
                 getCompatColor(R.color.white)
@@ -89,7 +85,9 @@ class UserIdView @JvmOverloads constructor(
         if (goodIdInfo != null && goodIdInfo.goodId != 0) {
             showEffectId = true
             binding.tvId.apply {
-                setPadding(20.dp(), 0, 0, 0)
+                updateLayoutParams<LayoutParams> {
+                    marginStart = 18.dp()
+                }
                 text = goodIdInfo.goodId.toString()
                 setTextColor(getCompatColor(R.color.white))
             }
@@ -136,10 +134,10 @@ class UserIdView @JvmOverloads constructor(
 
     private fun getIdTag(length: Int): IdTag {
         return when (length) {
-            8 -> IdTag("svip_8_digit_good_id.svga", 97.dp()) //173
-            7 -> IdTag("svip_7_digit_good_id.svga", 85.dp()) //152
-            6 -> IdTag("svip_6_digit_good_id.svga", 80.dp()) //143
-            else -> IdTag("svip_8_digit_good_id.svga", 97.dp())
+            8 -> IdTag("svip_8_digit_good_id.svga", 91.5f.dp()) //173
+            7 -> IdTag("svip_7_digit_good_id.svga", 80.5f.dp()) //152
+            6 -> IdTag("svip_6_digit_good_id.svga", 75.7f.dp()) //143
+            else -> IdTag("svip_8_digit_good_id.svga", 91.5f.dp())
         }
     }
 }

+ 8 - 6
app/src/main/res/layout/layout_user_id_view.xml

@@ -11,7 +11,7 @@
     <com.opensource.svgaplayer.WenextSvgaView
         android:id="@+id/svga_effect_id"
         android:layout_width="97dp"
-        android:layout_height="19dp"
+        android:layout_height="18dp"
         android:visibility="gone"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintStart_toStartOf="parent"
@@ -27,21 +27,23 @@
         android:textColor="@color/white"
         android:textSize="11sp"
         app:layout_constraintBottom_toBottomOf="@id/svga_effect_id"
-        app:layout_constraintStart_toStartOf="@id/svga_effect_id"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toStartOf="@id/iv_copy"
+        app:layout_constraintHorizontal_chainStyle="packed"
         app:layout_constraintTop_toTopOf="@id/svga_effect_id"
-        tools:paddingStart="19dp"
+        android:layout_marginStart="18dp"
         tools:text="12345678"
         tools:visibility="visible" />
 
     <androidx.appcompat.widget.AppCompatImageView
         android:id="@+id/iv_copy"
-        android:layout_width="12dp"
-        android:layout_height="12dp"
-        android:layout_marginEnd="5dp"
+        android:layout_width="14dp"
+        android:layout_height="14dp"
         android:src="@drawable/profile_copy_ic"
         android:visibility="gone"
         app:layout_constraintBottom_toBottomOf="@id/svga_effect_id"
         app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toEndOf="@id/tvId"
         app:layout_constraintTop_toTopOf="@id/svga_effect_id"
         tools:visibility="visible" />