Skip to content

Commit

Permalink
修复 tab_margin_x 不起作用的问题,该功能只支持 res 和 round
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzhengsr committed Dec 20, 2021
1 parent 5049bb2 commit 1550b6d
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 12 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ allprojects {

**如果你的工程的是androidx且想支持ViewPager2,可以关联tablibx库**
```
implementation 'com.github.LillteZheng:FlowHelper:v1.30'
implementation 'com.github.LillteZheng:FlowHelper:v1.31'
```
**support可以关联以下连接,请尽快切到androidx,support包不再维护**
```
Expand Down Expand Up @@ -144,6 +144,7 @@ implementation 'com.github.LillteZheng:FlowHelper:v1.30'


## 版本信息:
- v1.31 : 修复res和round,tab_margin_x 不起作用的问题
- v1.30 : 重构分离了ViewPager和非ViewPager的情况,并处理数据增加减少时,notifyDataChange()导致布局混乱的问题
- v1.291: 修复notifyDataChange部分场景不起作用的问题,小重构了参数配置
- v1.29 : 修复添加了tabWidth,round和res第一次不起作用的问题
Expand Down
8 changes: 4 additions & 4 deletions TAB_README3_0.md
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,10 @@ private void resFlow(){
|tab_height|dimension|指示器高度|
|tab_item_res|reference|指示器的背景,比如shape,bitmap等,只对 res 起作用|
|tab_round_size|dimension|圆角的大小,只对round起作用|
|tab_margin_l|dimension|左偏移|
|tab_margin_t|dimension|上偏移|
|tab_margin_r|dimension|右偏移|
|tab_margin_b|dimension|下偏移|
|tab_margin_l|dimension|左偏移,只支持type 为 res 或 round|
|tab_margin_t|dimension|上偏移,只支持type 为 res 或 round|
|tab_margin_r|dimension|右偏移,只支持type 为 res 或 round|
|tab_margin_b|dimension|下偏移,只支持type 为 res 或 round|
|tab_click_animTime|integer|点击动画的时间,默认300ms|
|tab_item_autoScale|boolean|开启放大缩小的效果|
|tab_scale_factor|float|放大倍数|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private void resFlow(){
bean.tabType = FlowConstants.RES;
bean.tabItemRes = R.drawable.shape_round;
bean.tabClickAnimTime = 300;
bean.tabMarginLeft = 5;
bean.tabMarginLeft = 30;
bean.tabMarginTop = 12;
bean.tabMarginRight = 5;
bean.tabMarginBottom = 10;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ public void refresh(View view) {
}

private void rectFlow() {
TabFlowLayout flowLayout = findViewById(R.id.rectflow);
/* TabFlowLayout flowLayout = findViewById(R.id.rectflow);
mAdapter = new TabApdater(R.layout.item_msg, mTitle);
flowLayout.setAdapter(mAdapter);
flowLayout.setAdapter(mAdapter);*/

TabFlowLayout flowLayout2 = findViewById(R.id.rectflow2);

Expand Down
4 changes: 3 additions & 1 deletion appx/src/main/res/layout/activity_tab.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
app:tab_height="3dp"
app:tab_width="20dp"
app:tab_margin_b="3dp"
app:tab_margin_l="10dp"
android:background="@color/black_ff_bg"
app:tab_scale_factor="1.2"
app:tab_item_autoScale="true"
Expand Down Expand Up @@ -67,6 +68,7 @@
app:tab_height="3dp"
app:tab_width="10dp"
app:tab_margin_b="3dp"
app:tab_margin_t="10dp"
android:background="@color/black_ff_bg"
android:layout_height="wrap_content"/>
<TextView
Expand All @@ -89,7 +91,7 @@
app:tab_margin_t="3dp"
app:tab_margin_b="3dp"
app:tab_margin_l="2dp"
app:tab_margin_r="2dp"
app:tab_margin_r="10dp"
app:tab_click_animTime="250"
android:layout_height="wrap_content"/>

Expand Down
7 changes: 6 additions & 1 deletion appx/src/main/res/layout/activity_tab_no_view_pager.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
android:paddingBottom="2dp"
app:tab_height="3dp"
app:tab_margin_b="1dp"
app:tab_margin_l="10dp"
app:tab_margin_r="20dp"
app:tab_item_autoScale="true"
app:tab_scale_factor="1.2"
app:tab_visual_count="2"
Expand Down Expand Up @@ -66,6 +68,8 @@
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="2dp"
app:tab_margin_l="10dp"
app:tab_margin_r="20dp"
android:paddingBottom="2dp"
android:layout_height="wrap_content"/>

Expand All @@ -79,6 +83,7 @@
app:tab_width="20dp"
app:tab_height="5dp"
app:tab_margin_b="2dp"
app:tab_margin_l="10dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="2dp"
Expand Down Expand Up @@ -106,7 +111,7 @@
app:tab_round_size="50dp"
app:tab_margin_t="4dp"
app:tab_margin_b="3dp"
app:tab_margin_l="2dp"
app:tab_margin_l="10dp"
app:tab_margin_r="2dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
Expand Down
2 changes: 2 additions & 0 deletions appx/src/main/res/layout/activity_vertical_tab.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
app:tab_orientation="vertical"
app:tab_width="2dp"
app:tab_height="20dp"
app:tab_margin_t="20dp"
app:tab_margin_b="5dp"
app:tab_action_orientaion="left"
android:background="@color/page_gray_cccc"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,13 @@ public void onPageScrolled(int position, float positionOffset, int positionOffse
left = left + positionOffset * (curView.getMeasuredWidth() + transView.getMeasuredWidth()) / 2;
right = left + mTabBean.tabWidth;
}
mTabRect.left = left;
mTabRect.right = right;
if (isSupportMargin()) {
mTabRect.left = left + mTabBean.tabMarginLeft;
mTabRect.right = right - mTabBean.tabMarginRight;
}else{
mTabRect.left = left ;
mTabRect.right = right;
}
valueChange(new TabValue(mTabRect.left, mTabRect.right));

mParentView.postInvalidate();
Expand Down Expand Up @@ -573,5 +578,13 @@ public void setContext(Context context){
mContext = context;
}

private boolean isSupportMargin(){
if (FlowConstants.RES == mTabBean.tabType||
FlowConstants.ROUND == mTabBean.tabType
){
return true;
}
return false;
}

}

0 comments on commit 1550b6d

Please sign in to comment.