Skip to content

Commit d9ebb7b

Browse files
author
食梦兽
committed
🚶 modify tab
1 parent 30df5cb commit d9ebb7b

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
lines changed

app/build.gradle

+3-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ dependencies {
5656
compile 'com.github.bumptech.glide:glide:4.0.0-SNAPSHOT'
5757
compile 'com.github.florent37:glidepalette:2.0.0'
5858
compile 'com.tbruyelle.rxpermissions:rxpermissions:0.9.1@aar'
59-
59+
compile('com.github.Andy671:Dachshund-Tab-Layout:v0.3.0') {
60+
exclude group: 'com.android.support'
61+
}
6062
// LeakCanary 检测内存泄露,打开后去 APP.java 中打开初始化 LeakCanary 代码
6163
// debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
6264
// releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'

app/src/main/java/me/bakumon/ugank/module/home/HomeActivity.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import android.support.design.widget.CoordinatorLayout;
1515
import android.support.design.widget.FloatingActionButton;
1616
import android.support.design.widget.Snackbar;
17-
import android.support.design.widget.TabLayout;
1817
import android.support.v4.view.ViewPager;
1918
import android.support.v7.app.AppCompatActivity;
2019
import android.support.v7.graphics.Palette;
@@ -25,6 +24,7 @@
2524
import com.bumptech.glide.Glide;
2625
import com.github.florent37.glidepalette.BitmapPalette;
2726
import com.github.florent37.glidepalette.GlidePalette;
27+
import com.kekstudio.dachshundtablayout.DachshundTabLayout;
2828

2929
import butterknife.BindView;
3030
import butterknife.ButterKnife;
@@ -51,8 +51,8 @@ public class HomeActivity extends AppCompatActivity implements HomeContract.View
5151
AppBarLayout mAppBarLayout;
5252
@BindView(R.id.iv_home_banner)
5353
ImageView mIvHomeBanner;
54-
@BindView(R.id.tl_home_category)
55-
TabLayout mTlHomeCategory;
54+
@BindView(R.id.tab_home_category)
55+
DachshundTabLayout mDachshundTabLayout;
5656
@BindView(R.id.vp_home_category)
5757
ViewPager mVpCategory;
5858
@BindView(R.id.collapsing_toolbar)
@@ -104,8 +104,7 @@ private void initView() {
104104
infoPagerAdapter.addFragment(resFragment);
105105

106106
mVpCategory.setAdapter(infoPagerAdapter);
107-
mTlHomeCategory.setupWithViewPager(mVpCategory);
108-
mTlHomeCategory.setTabGravity(TabLayout.GRAVITY_FILL);
107+
mDachshundTabLayout.setupWithViewPager(mVpCategory);
109108
mVpCategory.setCurrentItem(1);
110109
mVpCategory.setOffscreenPageLimit(6);
111110
}

app/src/main/res/layout/activity_home.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@
4646
android:layout_height="80dp"
4747
android:layout_gravity="bottom"
4848
android:gravity="bottom"
49+
android:paddingBottom="0dp"
4950
app:layout_collapseMode="pin">
5051

51-
<android.support.design.widget.TabLayout
52-
android:id="@+id/tl_home_category"
52+
<com.kekstudio.dachshundtablayout.DachshundTabLayout
53+
android:id="@+id/tab_home_category"
5354
style="@style/MyCustomTabLayout"
5455
android:layout_width="match_parent"
5556
android:layout_height="?attr/actionBarSize"
5657
app:tabMode="scrollable"/>
57-
5858
</android.support.v7.widget.Toolbar>
5959

6060
<LinearLayout

app/src/main/res/values/styles.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<style name="MyCustomTabLayout" parent="Widget.Design.TabLayout">
1212
<item name="tabIndicatorColor">@color/colorTabIndicator</item>
13-
<item name="tabIndicatorHeight">2dp</item>
13+
<item name="tabIndicatorHeight">0dp</item>
1414
<item name="tabBackground">@android:color/transparent</item>
1515
<item name="tabTextAppearance">@style/CustomTabTextAppearance</item>
1616
<item name="tabSelectedTextColor">@color/colorTabTextSelected</item>

build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ allprojects {
1818
maven {
1919
url "https://oss.sonatype.org/content/repositories/snapshots"
2020
}
21+
maven { url 'https://jitpack.io' }
2122
}
2223
}
2324

0 commit comments

Comments
 (0)