Skip to content

Commit

Permalink
[modify]
Browse files Browse the repository at this point in the history
修复tabwidth 不起作用的问题
  • Loading branch information
Zzhengsr committed May 16, 2021
1 parent 35bff13 commit 38fa86e
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 7 deletions.
4 changes: 2 additions & 2 deletions TAB_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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|左偏移|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();


}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 38fa86e

Please sign in to comment.