Skip to content

Commit

Permalink
1、修复设置固定个数后,在网络的加载中,失败的问题
Browse files Browse the repository at this point in the history
2、增加提示,固定个数必须是 match_parent 或者 固定宽度
  • Loading branch information
Zzhengsr committed May 25, 2020
1 parent 331f409 commit ecd387f
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 122 deletions.
3 changes: 3 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 0 additions & 37 deletions .idea/inspectionProfiles/Project_Default.xml

This file was deleted.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ allprojects {
```

```
implementation 'com.github.LillteZheng:FlowHelper:v1.22'
implementation 'com.github.LillteZheng:FlowHelper:v1.23'
```

**如果要支持 AndroidX ,如果你的工程已经有以下代码,直接关联即可:**
Expand Down
5 changes: 3 additions & 2 deletions TAB_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

**关于宽度,以下请须知:**

- **设置了 tab_visual_count ,则根据固定宽度或者屏幕宽度的宽度去均分;其他则是根据子控件的大小去累加宽度,所以需要写好子控件的大小**
- **设置了 tab_visual_count,宽度需要设置成**match_parent或者固定宽度**;其他则是根据子控件的大小去累加宽度,一般建议子控件为 wrap_content**

- **用到约束布局,或者 LinearLayout,当你是居中而没有向左对齐,当子控件过多,则代码会手动让它向左对齐,这样滚动和布局才会正常**

Expand Down Expand Up @@ -301,7 +301,8 @@ private void resFlow(){

上面中,item_layout 的宽度都是通过测量自身的,如果想要均分宽度怎么做呢?

可以设置 tab_visual_count ,当前可视个数来试下,比如当前可视界面只显示3个:
可以设置 tab_visual_count ,宽度需要设置成**match_parent或者固定宽度**,如果是子控件是 textview,建议 gravity 设置成
center居中,比如当前可视界面只显示3个:
<img src="https://github.com/LillteZheng/FlowHelper/raw/master/gif/tab_visual_count.png" >


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ protected void onCreate(Bundle savedInstanceState) {
final TabFlowAdapter adapter ;
flowLayout.setViewPager(mViewPager)
.setTextId(R.id.item_text)
.setDefaultPosition(2);
.setDefaultPosition(2)
.setVisualCount(4);
flowLayout.setAdapter(adapter = new TabFlowAdapter<String>(R.layout.item_tab,titles) {

@Override
Expand Down Expand Up @@ -79,7 +80,8 @@ public void onNext(BaseResponse<List<SystematicBean>> baseResponse) {
fragments.add(RecyclerFragment.newInstance(child));
}
mViewPager.setAdapter(new ViewPagerAdapter(getSupportFragmentManager(),fragments));
adapter.notifyDataChanged();
//刷新数据
adapter.notifyDataChanged();


}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_net_test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<com.zhengsr.tablib.view.flow.TabFlowLayout
android:id="@+id/tabflow"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_marginTop="5dp"
app:layout_constraintTop_toTopOf="@id/normal_view"
app:layout_constraintStart_toStartOf="@id/normal_view"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/item_tab.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
app:colortext_default_color="@color/unselect"
app:colortext_change_color="@color/white"
android:textSize="14sp"
android:gravity="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

buildscript {
repositories {
google()
jcenter()

google()

}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.android.tools.build:gradle:3.5.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -16,8 +16,8 @@ buildscript {

allprojects {
repositories {
google()
jcenter()
google()
maven { url 'https://jitpack.io' }

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,9 @@ private void measureTabHorizontal(int widthMeasureSpec, int heightMeasureSpec) {
//拿到 子控件高度,拿到最大的那个高度
height = Math.max(height, ch);




}


//具体大小,padding不受影响
if (MeasureSpec.EXACTLY == heightMode) {
height = heightSize;
Expand Down
Loading

0 comments on commit ecd387f

Please sign in to comment.