diff --git a/TAB_README.md b/TAB_README.md index f77ae55..5eef4a3 100644 --- a/TAB_README.md +++ b/TAB_README.md @@ -356,8 +356,8 @@ center居中,比如当前可视界面只显示3个: |---|---|---| |tab_type|rect,tri,round,color,res|tab的类型,目前支持矩形,三角形、圆角、颜色渐变、资源res| |tab_color|color|指示器的颜色,当类型为 rect、tri、roud是可以通过它定义| -|tab_width|dimension|指示器的宽度,默认根据控件自身大小,部分支持| -|tab_height|dimension|指示器高度| +|tab_width|dimension|指示器的宽度,默认根据控件自身大小| +|tab_height|dimension|指示器高度,只支持tri和rect| |tab_item_res|reference|指示器的背景,比如shape,bitmap等,只对 res 起作用| |tab_round_size|dimension|圆角的大小,只对round起作用| |tab_margin_l|dimension|左偏移| diff --git a/appx/src/main/java/com/zhengsr/tabhelper/activity/TabActivity.java b/appx/src/main/java/com/zhengsr/tabhelper/activity/TabActivity.java index 07ac1f9..b01becb 100644 --- a/appx/src/main/java/com/zhengsr/tabhelper/activity/TabActivity.java +++ b/appx/src/main/java/com/zhengsr/tabhelper/activity/TabActivity.java @@ -45,12 +45,12 @@ protected void onCreate(Bundle savedInstanceState) { } mViewPager.setAdapter(new CusAdapter2(this)); mViewPager.setOffscreenPageLimit(3); - rectFlow(); - triFlow(); - roundFlow(); + // rectFlow(); + // triFlow(); + // roundFlow(); resFlow(); - colorFlow(); - cusFlow(); + // colorFlow(); + // cusFlow(); } diff --git a/tablib/src/main/java/com/zhengsr/tablib/view/action/ResAction.java b/tablib/src/main/java/com/zhengsr/tablib/view/action/ResAction.java index 28cf7e9..941229f 100644 --- a/tablib/src/main/java/com/zhengsr/tablib/view/action/ResAction.java +++ b/tablib/src/main/java/com/zhengsr/tablib/view/action/ResAction.java @@ -52,6 +52,10 @@ public void config(TabFlowLayout parentView) { float b = child.getBottom() - mTabBean.tabMarginBottom; mDrawable.setBounds(0, 0, width, height); mDrawable.draw(canvas); + if (mTabBean.tabWidth != -1) { + l += (child.getMeasuredWidth() - mTabBean.tabWidth) / 2 ; + r = mTabBean.tabWidth + l; + } mTabRect.set(l, t, r, b); mSrcRect = new Rect(0, 0, width, height); diff --git a/tablib/src/main/java/com/zhengsr/tablib/view/action/RoundAction.java b/tablib/src/main/java/com/zhengsr/tablib/view/action/RoundAction.java index 141f6fe..d648018 100644 --- a/tablib/src/main/java/com/zhengsr/tablib/view/action/RoundAction.java +++ b/tablib/src/main/java/com/zhengsr/tablib/view/action/RoundAction.java @@ -38,6 +38,10 @@ public void config(TabFlowLayout parentView) { float t = mTabBean.tabMarginTop + child.getTop(); float r = child.getRight() - mTabBean.tabMarginRight; float b = child.getBottom() - mTabBean.tabMarginBottom; + if (mTabBean.tabWidth != -1) { + l += (child.getMeasuredWidth() - mTabBean.tabWidth) / 2 ; + r = mTabBean.tabWidth + l; + } mTabRect.set(l, t, r, b); } parentView.postInvalidate(); diff --git a/tablibx/src/main/java/com/zhengsr/tablib/view/action/ResAction.java b/tablibx/src/main/java/com/zhengsr/tablib/view/action/ResAction.java index 3cdbdd7..3c58516 100644 --- a/tablibx/src/main/java/com/zhengsr/tablib/view/action/ResAction.java +++ b/tablibx/src/main/java/com/zhengsr/tablib/view/action/ResAction.java @@ -50,6 +50,10 @@ public void config(TabFlowLayout parentView) { float b = child.getBottom() - mTabBean.tabMarginBottom; mDrawable.setBounds(0, 0, width, height); mDrawable.draw(canvas); + if (mTabBean.tabWidth != -1) { + l += (child.getMeasuredWidth() - mTabBean.tabWidth) / 2 ; + r = mTabBean.tabWidth + l; + } mTabRect.set(l, t, r, b); mSrcRect = new Rect(0, 0, width, height); diff --git a/tablibx/src/main/java/com/zhengsr/tablib/view/action/RoundAction.java b/tablibx/src/main/java/com/zhengsr/tablib/view/action/RoundAction.java index 95551e5..a807aab 100644 --- a/tablibx/src/main/java/com/zhengsr/tablib/view/action/RoundAction.java +++ b/tablibx/src/main/java/com/zhengsr/tablib/view/action/RoundAction.java @@ -1,6 +1,7 @@ package com.zhengsr.tablib.view.action; import android.graphics.Canvas; +import android.util.Log; import android.view.View; import com.zhengsr.tablib.bean.TabBean; @@ -35,6 +36,10 @@ public void config(TabFlowLayout parentView) { float t = mTabBean.tabMarginTop + child.getTop(); float r = child.getRight() - mTabBean.tabMarginRight; float b = child.getBottom() - mTabBean.tabMarginBottom; + if (mTabBean.tabWidth != -1) { + l += (child.getMeasuredWidth() - mTabBean.tabWidth) / 2 ; + r = mTabBean.tabWidth + l; + } mTabRect.set(l, t, r, b); } parentView.postInvalidate();