diff --git a/FlycoTabLayout_Lib/build.gradle b/FlycoTabLayout_Lib/build.gradle index 166f8c62..67db052b 100644 --- a/FlycoTabLayout_Lib/build.gradle +++ b/FlycoTabLayout_Lib/build.gradle @@ -24,7 +24,7 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:support-v4:25.1.0' + compile 'com.android.support:support-v4:25+' } //def siteUrl = 'https://github.com/H07000223' // 项目的主页 diff --git a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SlidingTabLayout.java b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SlidingTabLayout.java index 9ab7e5ed..6506c1e5 100644 --- a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SlidingTabLayout.java +++ b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SlidingTabLayout.java @@ -43,7 +43,7 @@ public class SlidingTabLayout extends HorizontalScrollView implements ViewPager. private float mCurrentPositionOffset; private int mTabCount; /** 用于绘制显示器 */ - private Rect mIndicatorRect = new Rect(); + protected Rect mIndicatorRect = new Rect(); /** 用于实现滚动居中 */ private Rect mTabRect = new Rect(); private GradientDrawable mIndicatorDrawable = new GradientDrawable(); diff --git a/app/build.gradle b/app/build.gradle index f2f86d4d..e0b368e5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -21,11 +21,11 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:25.1.0' -// compile project(':FlycoTabLayout_Lib') + compile 'com.android.support:appcompat-v7:25+' + compile project(':FlycoTabLayout_Lib') //--->support 3.0+ - compile 'com.flyco.tablayout:FlycoTabLayout_Lib:2.1.2@aar' +// compile 'com.flyco.tablayout:FlycoTabLayout_Lib:2.1.2@aar' //--->support 2.2+ // compile 'com.flyco.tablayout:FlycoTabLayout_Lib:2.0.0@aar' // compile 'com.nineoldandroids:library:2.4.0' diff --git a/app/src/main/java/com/flyco/tablayoutsamples/ui/SlidingTabActivity.java b/app/src/main/java/com/flyco/tablayoutsamples/ui/SlidingTabActivity.java index 290c9b03..39f0d40e 100644 --- a/app/src/main/java/com/flyco/tablayoutsamples/ui/SlidingTabActivity.java +++ b/app/src/main/java/com/flyco/tablayoutsamples/ui/SlidingTabActivity.java @@ -62,7 +62,8 @@ protected void onCreate(Bundle savedInstanceState) { /** indicator圆角色块 */ SlidingTabLayout tabLayout_9 = ViewFindUtils.find(decorView, R.id.tl_9); /** indicator圆角色块 */ - SlidingTabLayout tabLayout_10 = ViewFindUtils.find(decorView, R.id.tl_10); + SlidingTabLayoutV2 tabLayout_10 = ViewFindUtils.find(decorView, R.id.tl_10); + tabLayout_10.setmIndicatorDrawable(getResources().getDrawable(R.drawable.icon_tablayout_indicator)); tabLayout_1.setViewPager(vp); tabLayout_2.setViewPager(vp); diff --git a/app/src/main/java/com/flyco/tablayoutsamples/ui/SlidingTabLayoutV2.java b/app/src/main/java/com/flyco/tablayoutsamples/ui/SlidingTabLayoutV2.java new file mode 100644 index 00000000..65094e8d --- /dev/null +++ b/app/src/main/java/com/flyco/tablayoutsamples/ui/SlidingTabLayoutV2.java @@ -0,0 +1,43 @@ +package com.flyco.tablayoutsamples.ui; + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.Drawable; +import android.graphics.drawable.GradientDrawable; +import android.util.AttributeSet; +import android.view.Gravity; + +import com.flyco.tablayout.SlidingTabLayout; + +public class SlidingTabLayoutV2 extends SlidingTabLayout { + public SlidingTabLayoutV2(Context context) { + super(context); + } + + public SlidingTabLayoutV2(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public SlidingTabLayoutV2(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + private Drawable mIndicatorDrawable = new BitmapDrawable(); + + public void setmIndicatorDrawable(Drawable mIndicatorDrawable) { + this.mIndicatorDrawable = mIndicatorDrawable; + } + + @Override + protected void onDraw(Canvas canvas) { + mIndicatorDrawable.setBounds(getPaddingLeft() + (int) getIndicatorMarginLeft() + mIndicatorRect.left, + getHeight() - 50, + getPaddingLeft() + mIndicatorRect.right - (int) getIndicatorMarginRight(), + getHeight() - (int) getIndicatorMarginBottom()); + + mIndicatorDrawable.draw(canvas); + super.onDraw(canvas); + + } +} diff --git a/app/src/main/res/drawable-xxhdpi/icon_tablayout_indicator.png b/app/src/main/res/drawable-xxhdpi/icon_tablayout_indicator.png new file mode 100644 index 00000000..712f504d Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/icon_tablayout_indicator.png differ diff --git a/app/src/main/res/drawable/background_card.9.png b/app/src/main/res/drawable/background_card.9.png index 8cbd7afa..8c5bc677 100644 Binary files a/app/src/main/res/drawable/background_card.9.png and b/app/src/main/res/drawable/background_card.9.png differ diff --git a/app/src/main/res/layout/activity_sliding_tab.xml b/app/src/main/res/layout/activity_sliding_tab.xml index 3df558dd..fb2ee5d1 100644 --- a/app/src/main/res/layout/activity_sliding_tab.xml +++ b/app/src/main/res/layout/activity_sliding_tab.xml @@ -109,18 +109,19 @@ tl:tl_indicator_margin_right="2dp" tl:tl_indicator_style="BLOCK"/> - + /> diff --git a/build.gradle b/build.gradle index 062f3830..63ffa762 100644 --- a/build.gradle +++ b/build.gradle @@ -3,6 +3,10 @@ buildscript { repositories { jcenter() + maven { + url 'https://maven.google.com/' + name 'Google' + } } dependencies { classpath 'com.android.tools.build:gradle:2.2.3' @@ -16,6 +20,10 @@ buildscript { allprojects { repositories { jcenter() + maven { + url 'https://maven.google.com/' + name 'Google' + } // maven { // url "http://dl.bintray.com/h07000223/maven" // }