Skip to content

Commit

Permalink
增加rect根据text的宽度来
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzhengsr committed Feb 14, 2022
1 parent 4eb40f8 commit 6128dec
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 52 deletions.
1 change: 1 addition & 0 deletions TAB_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ private void resFlow(){
|tab_action_orientaion|integer|left坐标,right右边,只支持 tri、rect 两种效果|
|tab_isAutoScroll|boolean|是否支持自动滚动,默认为true|
|tab_visual_count|integer|可视化个数,比如有一排,我们就只要显示4个,此时宽度均分|
|tab_width_equals_text|boolean|rect 是否根据text的大小来,目前只支持rect和带viewpager的情况|


**TabColorTextView**
Expand Down
4 changes: 2 additions & 2 deletions appx/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

//implementation project(path: ':tablibx')
implementation 'com.github.LillteZheng:FlowHelper:v1.33'
implementation project(path: ':tablibx')
//implementation 'com.github.LillteZheng:FlowHelper:v1.34'
implementation 'me.yokeyword:fragmentationx:1.0.2'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.viewpager2:viewpager2:1.0.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.zhengsr.tabhelper.R;
import com.zhengsr.tablib.FlowConstants;
import com.zhengsr.tablib.bean.TabBean;
import com.zhengsr.tablib.bean.TabConfig;
import com.zhengsr.tablib.bean.TabValue;
import com.zhengsr.tablib.view.action.BaseAction;
import com.zhengsr.tablib.view.adapter.TabFlowAdapter;
Expand All @@ -37,6 +38,8 @@ protected void onCreate(Bundle savedInstanceState) {
// mTitle.add("Kotlin");
setContentView(R.layout.activity_tab_no_view_pager);
TabFlowLayout flowLayout = findViewById(R.id.new_test);
TabConfig config = new TabConfig.Builder()
.setTextId(R.id.item_text).build();
flowLayout.setAdapter(new TabFlowAdapter<String>(R.layout.item_msg, mTitle) {
@Override
public void bindView(View view, String data, int position) {
Expand Down
2 changes: 1 addition & 1 deletion appx/src/main/res/layout/activity_tab.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
app:tab_type="rect"
app:tab_height="2dp"
app:tab_color="@color/colorAccent"
app:tab_margin_b="3dp"
app:tab_width_equals_text="true"
android:layout_height="wrap_content"/>

<TextView
Expand Down
1 change: 1 addition & 0 deletions appx/src/main/res/layout/activity_tab_no_view_pager.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
app:tab_item_autoScale="true"
app:tab_scale_factor="1.2"
app:tab_visual_count="2"
app:tab_width_equals_text="true"
/>

<com.zhengsr.tablib.view.flow.TabFlowLayout
Expand Down
5 changes: 5 additions & 0 deletions tablibx/src/main/java/com/zhengsr/tablib/bean/TabBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ public class TabBean {
public int visualCount = -1;


/**
* tab 的宽度是否跟随text的宽度大小,只对 rect 有用
*/
public boolean tabWidthEqualsText = true;

@Override
public String toString() {
return "TabBean{" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public static TabBean getTabBean(TypedArray ta){
bean.actionOrientation = ta.getInteger(R.styleable.AbsFlowLayout_tab_action_orientaion,-1);
bean.isAutoScroll = ta.getBoolean(R.styleable.AbsFlowLayout_tab_isAutoScroll, true);
bean.visualCount = ta.getInteger(R.styleable.AbsFlowLayout_tab_visual_count, -1);
bean.tabWidthEqualsText = ta.getBoolean(R.styleable.AbsFlowLayout_tab_width_equals_text,true);

return bean;
}
Expand Down
Loading

0 comments on commit 6128dec

Please sign in to comment.