浏览代码

CommonUserItemView.java 修改

niusongtao@dl-cg.com 5 年之前
父节点
当前提交
a89e909dd3

+ 7 - 0
base_library/src/main/java/com/mgtech/base_library/custom/CommonUserItemView.java

@@ -17,6 +17,7 @@ import androidx.constraintlayout.widget.ConstraintSet;
 import androidx.core.content.ContextCompat;
 
 import com.mgtech.base_library.R;
+import com.mgtech.base_library.util.DrawableUtil;
 
 /**
  * @ProjectName: ShellApplication
@@ -134,6 +135,12 @@ public class CommonUserItemView extends ConstraintLayout {
         LayoutParams layoutParams = (LayoutParams) titleText.getLayoutParams();
         layoutParams.setMargins(0,top,0,bottom);
         titleText.setLayoutParams(layoutParams);
+
+
+        int start = typedArray.getDimensionPixelSize(R.styleable.CommonUserItemView_item_padding_start, DrawableUtil.Dp2Px(15));
+        int end = typedArray.getDimensionPixelSize(R.styleable.CommonUserItemView_item_padding_end,DrawableUtil.Dp2Px(15));
+        setPadding(start,getPaddingTop(),end,getPaddingBottom());
+
         typedArray.recycle();
     }
 

+ 3 - 4
base_library/src/main/res/layout/layout_common_user_item.xml

@@ -25,7 +25,7 @@
         app:layout_constraintStart_toEndOf="@+id/item_left_image"
         app:layout_constraintEnd_toStartOf="@id/item_detail_text"
         app:layout_constraintTop_toTopOf="parent"
-        app:layout_goneMarginStart="@dimen/dp_15" />
+        app:layout_goneMarginStart="@dimen/dp_0" />
 
     <TextView
         android:id="@+id/item_detail_text"
@@ -36,18 +36,17 @@
         android:gravity="end"
         android:textColor="@color/gray_text_light"
         android:textSize="@dimen/sp_14"
+        app:layout_goneMarginEnd="@dimen/dp_0"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintEnd_toStartOf="@+id/item_right_image"
         app:layout_constraintStart_toEndOf="@+id/item_title_text"
-        app:layout_constraintTop_toTopOf="parent"
-        app:layout_goneMarginEnd="@dimen/dp_15" />
+        app:layout_constraintTop_toTopOf="parent" />
 
 
     <ImageView
         android:id="@+id/item_right_image"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_marginEnd="@dimen/dp_15"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintTop_toTopOf="parent" />

+ 2 - 0
base_library/src/main/res/values/attrs.xml

@@ -97,6 +97,8 @@
         <attr name="item_detail_text_size" format="dimension"/>
         <attr name="item_detail_text_drawable" format="reference"/>
         <attr name="item_detail_text_drawable_padding" format="dimension"/>
+        <attr name="item_padding_start" format="dimension"/>
+        <attr name="item_padding_end" format="dimension"/>
         <attr name="item_padding_top" format="dimension"/>
         <attr name="item_padding_bottom" format="dimension"/>
         <attr name="item_line_margin_start" format="dimension"/>