Эх сурвалжийг харах

添加部分tab页基础选中样式

Frankensteinly 10 сар өмнө
parent
commit
7ee650da88

+ 5 - 0
app/src/main/java/com/grkj/iscs/view/activity/HomeActivity.kt

@@ -36,7 +36,12 @@ class HomeActivity : BaseMvpActivity<IHomeView, HomePresenter, ActivityHomeBindi
                 holder.setText(R.id.tv_number, data?.title)
                 holder.setOnClickListener(R.id.root) {
                     mBinding?.vp?.currentItem = position
+                    notifyDataSetChanged()
                 }
+                holder.setBackgroundColor(R.id.root,
+                    if (position == mBinding?.vp?.currentItem)
+                        getColor(R.color.common_bg_white_30)
+                    else 0)
             }
         }
     }

+ 3 - 1
app/src/main/java/com/grkj/iscs/view/fragment/JobManagementFragment.kt

@@ -33,12 +33,14 @@ class JobManagementFragment :
 
         mBinding?.rvTab?.adapter = object : CommonAdapter<Menu>(activity, R.layout.item_rv_job_management, mMenuList) {
             override fun convert(holder: ViewHolder, t: Menu?, position: Int) {
-                holder.setText(R.id.tv_number, t?.title)
+                holder.setText(R.id.tv_name, t?.title)
                 holder.setOnClickListener(R.id.root) {
                     if (position == 0) {
                         mBinding?.vp?.currentItem = 0
+                        notifyDataSetChanged()
                     }
                 }
+                holder.setVisible(R.id.v_indicator, position == mBinding?.vp?.currentItem)
             }
         }
     }

+ 25 - 8
app/src/main/res/layout/item_rv_job_management.xml

@@ -1,17 +1,34 @@
 <?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     android:id="@+id/root"
     android:layout_width="wrap_content"
-    android:layout_height="wrap_content"
-    android:layout_margin="@dimen/rv_item_margin"
-    android:orientation="horizontal">
+    android:layout_height="wrap_content">
 
     <ImageView
+        android:id="@+id/iv"
         android:layout_width="wrap_content"
-        android:layout_height="wrap_content"/>
+        android:layout_height="wrap_content"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
 
     <TextView
-        android:id="@+id/tv_number"
-        style="@style/CommonTextView" />
+        android:id="@+id/tv_name"
+        style="@style/CommonTextView"
+        android:layout_marginBottom="@dimen/divider_line_margin"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintLeft_toRightOf="@id/iv"
+        app:layout_constraintTop_toTopOf="parent" />
 
-</LinearLayout>
+    <View
+        android:id="@+id/v_indicator"
+        android:layout_width="0dp"
+        android:layout_height="@dimen/divider_line_width"
+        android:layout_below="@id/iv"
+        android:background="@color/tab_indicator"
+        android:visibility="gone"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toBottomOf="@id/tv_name" />
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 0 - 2
app/src/main/res/layout/item_rv_menu.xml

@@ -3,11 +3,9 @@
     android:id="@+id/root"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:layout_margin="@dimen/rv_item_margin"
     android:orientation="vertical">
 
     <TextView
         android:id="@+id/tv_number"
         style="@style/CommonTextView" />
-
 </LinearLayout>

+ 2 - 0
app/src/main/res/values/colors.xml

@@ -20,4 +20,6 @@
     <color name="selectable_input_prefix">#bd3124</color>
     <color name="switch_track_on">#298EFF</color>
     <color name="switch_track_off">#E9E9E9</color>
+
+    <color name="tab_indicator">#64b0f4</color>
 </resources>