Răsfoiți Sursa

修正ExpandableTabLayout显示效果;首页补充显示控件

Frankensteinly 8 luni în urmă
părinte
comite
de0d7d6736

+ 16 - 7
app/src/main/java/com/grkj/iscs_mc/view/widget/ExpandableTabLayout.kt

@@ -33,6 +33,7 @@ class ExpandableTabLayout(private val ctx: Context, attrs: AttributeSet) :
     private var mOnSelectListener: OnSelectListener? = null
     private var isInteractive = false
     private var mSelectIndex = 0
+    private var mDirection: Int = DOWNWARDS
 
     init {
         val root = View.inflate(ctx, R.layout.layout_expandable_tab_layout, this)
@@ -40,10 +41,12 @@ class ExpandableTabLayout(private val ctx: Context, attrs: AttributeSet) :
 
         val attrSet = ctx.obtainStyledAttributes(attrs, R.styleable.ExpandableTabLayout)
 
-        val direction = attrSet.getInt(R.styleable.ExpandableTabLayout_expand_direction, 0)
-        if (direction == 1) {
+        mDirection = attrSet.getInt(R.styleable.ExpandableTabLayout_expand_direction, DOWNWARDS)
+        if (mDirection == UPWARDS) {
             mBinding.ivAction.rotation = 180f
-            mBinding.root.background = AppCompatResources.getDrawable(ctx, R.drawable.expandable_tab_bg_bottom)
+            mBinding.root.setBackgroundResource(R.drawable.expandable_tab_bg_bottom)
+        } else {
+            mBinding.root.setBackgroundResource(R.drawable.expandable_tab_bg_top)
         }
 
         // 是否要联动下划线
@@ -74,9 +77,11 @@ class ExpandableTabLayout(private val ctx: Context, attrs: AttributeSet) :
                         holder.setText(R.id.tv_name, it)
                     }
                     holder.setOnClickListener(R.id.root) {
-                        mOnSelectListener?.onSelect(position)
-                        mBinding.rvTab.adapter?.notifyDataSetChanged()
-                        mSelectIndex = position
+                        if (isInteractive) {
+                            mOnSelectListener?.onSelect(position)
+                            mBinding.rvTab.adapter?.notifyDataSetChanged()
+                            mSelectIndex = position
+                        }
                     }
                 }
             }
@@ -106,7 +111,11 @@ class ExpandableTabLayout(private val ctx: Context, attrs: AttributeSet) :
             }
             isCollapse = !isCollapse
 
-            mBinding.ivAction.rotation = if (isCollapse) 0f else 180f
+            mBinding.ivAction.rotation = if (isCollapse) {
+                if (mDirection == DOWNWARDS) 0f else 180f
+            } else {
+                if (mDirection == DOWNWARDS) 180f else 0f
+            }
         }
     }
 

+ 1 - 1
app/src/main/res/drawable/expandable_tab_bg_bottom.xml

@@ -2,5 +2,5 @@
 <shape xmlns:android="http://schemas.android.com/apk/res/android"
     android:shape="rectangle">
     <solid android:color="#3e6aa5" />
-    <corners android:radius="@dimen/common_radius_big" />
+    <corners android:radius="@dimen/common_radius" />
 </shape>

+ 10 - 11
app/src/main/res/layout/fragment_material_home.xml

@@ -14,21 +14,11 @@
         app:bar_icon="@mipmap/material_management"
         app:bar_title="@string/material_management" />
 
-    <RelativeLayout
-        android:id="@+id/rl_status"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_alignParentBottom="true"
-        android:background="@drawable/item_rv_technology_sop_bg_normal"
-        android:padding="@dimen/common_spacing_small">
-
-    </RelativeLayout>
-
     <androidx.constraintlayout.widget.ConstraintLayout
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:layout_above="@id/rl_status"
         android:layout_below="@id/tb"
+        android:layout_marginBottom="50dp"
         android:background="@drawable/item_rv_technology_sop_bg_normal">
 
         <RelativeLayout
@@ -171,4 +161,13 @@
                 android:textSize="@dimen/common_text_size_small" />
         </RelativeLayout>
     </androidx.constraintlayout.widget.ConstraintLayout>
+
+    <com.grkj.iscs_mc.view.widget.ExpandableTabLayout
+        android:id="@+id/etl_type"
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/expandable_tab_collapse_height"
+        android:layout_alignParentBottom="true"
+        app:expand_direction="upwards"
+        app:interactive="true"
+        app:expand_title="@string/home_status_bar_title"/>
 </RelativeLayout>

+ 2 - 3
app/src/main/res/layout/layout_expandable_tab_layout.xml

@@ -2,8 +2,7 @@
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/root"
     android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:background="@drawable/expandable_tab_bg_top">
+    android:layout_height="wrap_content">
 
     <ImageView
         android:id="@+id/iv_action"
@@ -24,7 +23,7 @@
         <TextView
             android:id="@+id/tv_title"
             style="@style/CommonTextView"
-            android:layout_marginLeft="@dimen/common_spacing_small"
+            android:layout_marginLeft="@dimen/common_spacing"
             android:layout_marginTop="12dp"
             android:layout_marginBottom="@dimen/common_spacing_small" />
 

+ 2 - 2
app/src/main/res/values/attrs.xml

@@ -32,8 +32,8 @@
 
     <declare-styleable name="ExpandableTabLayout">
         <attr name="expand_direction">
-            <flag name="upwards" value="0x00000000" />
-            <flag name="downwards" value="0x00000001" />
+            <flag name="downwards" value="0x00000000" />
+            <flag name="upwards" value="0x00000001" />
         </attr>
         <attr name="interactive" format="boolean" />
         <attr name="expand_title" format="string" />