diff --git a/CHNAGELOG.md b/CHNAGELOG.md
index 9e02bb2a..84ade8f7 100644
--- a/CHNAGELOG.md
+++ b/CHNAGELOG.md
@@ -71,3 +71,8 @@ Version 2.0.6 *(2016.5.21)*
* remove CustomTabProvider in SlidingTabLayout
* new added method 'addNewTab(String title)' for SlidingTabLayout
+Version 2.0.8 *(2016.7.26)*
+---------------------------
+* Fix #27,#31(new added method 'setCurrentTab(int currentTab, boolean smoothScroll)' for SlidingTabLayout and redefine attr 'tl_textBold')
+
+
diff --git a/FlycoTabLayout_Lib/build.gradle b/FlycoTabLayout_Lib/build.gradle
index 41be4abf..da8100a2 100644
--- a/FlycoTabLayout_Lib/build.gradle
+++ b/FlycoTabLayout_Lib/build.gradle
@@ -3,7 +3,7 @@ apply plugin: 'com.android.library'
//apply plugin: 'com.jfrog.bintray'
// 这个version是区分library版本的,因此当我们需要更新library时记得修改这个version
-version = "2.0.6"
+version = "2.0.8"
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
@@ -11,7 +11,7 @@ android {
defaultConfig {
minSdkVersion 11
targetSdkVersion 23
- versionCode 206
+ versionCode 208
versionName version
}
buildTypes {
@@ -25,8 +25,6 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:23.4.0'
-// compile 'com.android.support:appcompat-v7:23.4.0'
-// compile 'com.nineoldandroids:library:2.4.0'
}
//def siteUrl = 'https://github.com/H07000223' // 项目的主页
diff --git a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/CommonTabLayout.java b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/CommonTabLayout.java
index 1bde0a9a..b0db9cd1 100644
--- a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/CommonTabLayout.java
+++ b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/CommonTabLayout.java
@@ -84,10 +84,13 @@ public class CommonTabLayout extends FrameLayout implements ValueAnimator.Animat
private float mDividerPadding;
/** title */
+ private static final int TEXT_BOLD_NONE = 0;
+ private static final int TEXT_BOLD_WHEN_SELECT = 1;
+ private static final int TEXT_BOLD_BOTH = 2;
private float mTextsize;
private int mTextSelectColor;
private int mTextUnselectColor;
- private boolean mTextBold;
+ private int mTextBold;
private boolean mTextAllCaps;
/** icon */
@@ -171,7 +174,7 @@ private void obtainAttributes(Context context, AttributeSet attrs) {
mTextsize = ta.getDimension(R.styleable.CommonTabLayout_tl_textsize, sp2px(13f));
mTextSelectColor = ta.getColor(R.styleable.CommonTabLayout_tl_textSelectColor, Color.parseColor("#ffffff"));
mTextUnselectColor = ta.getColor(R.styleable.CommonTabLayout_tl_textUnselectColor, Color.parseColor("#AAffffff"));
- mTextBold = ta.getBoolean(R.styleable.CommonTabLayout_tl_textBold, false);
+ mTextBold = ta.getInt(R.styleable.CommonTabLayout_tl_textBold, TEXT_BOLD_NONE);
mTextAllCaps = ta.getBoolean(R.styleable.CommonTabLayout_tl_textAllCaps, false);
mIconVisible = ta.getBoolean(R.styleable.CommonTabLayout_tl_iconVisible, true);
@@ -273,8 +276,10 @@ private void updateTabStyles() {
tv_tab_title.setText(tv_tab_title.getText().toString().toUpperCase());
}
- if (mTextBold) {
- tv_tab_title.getPaint().setFakeBoldText(mTextBold);
+ if (mTextBold == TEXT_BOLD_BOTH) {
+ tv_tab_title.getPaint().setFakeBoldText(true);
+ } else if (mTextBold == TEXT_BOLD_NONE) {
+ tv_tab_title.getPaint().setFakeBoldText(false);
}
ImageView iv_tab_icon = (ImageView) tabView.findViewById(R.id.iv_tab_icon);
@@ -311,6 +316,9 @@ private void updateTabSelection(int position) {
ImageView iv_tab_icon = (ImageView) tabView.findViewById(R.id.iv_tab_icon);
CustomTabEntity tabEntity = mTabEntitys.get(i);
iv_tab_icon.setImageResource(isSelect ? tabEntity.getTabSelectedIcon() : tabEntity.getTabUnselectedIcon());
+ if (mTextBold == TEXT_BOLD_WHEN_SELECT) {
+ tab_title.getPaint().setFakeBoldText(isSelect);
+ }
}
}
@@ -600,7 +608,7 @@ public void setTextUnselectColor(int textUnselectColor) {
updateTabStyles();
}
- public void setTextBold(boolean textBold) {
+ public void setTextBold(int textBold) {
this.mTextBold = textBold;
updateTabStyles();
}
@@ -736,7 +744,7 @@ public int getTextUnselectColor() {
return mTextUnselectColor;
}
- public boolean isTextBold() {
+ public int getTextBold() {
return mTextBold;
}
diff --git a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SegmentTabLayout.java b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SegmentTabLayout.java
index a7a96bb4..e9df2953 100644
--- a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SegmentTabLayout.java
+++ b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SegmentTabLayout.java
@@ -66,10 +66,13 @@ public class SegmentTabLayout extends FrameLayout implements ValueAnimator.Anima
private float mDividerPadding;
/** title */
+ private static final int TEXT_BOLD_NONE = 0;
+ private static final int TEXT_BOLD_WHEN_SELECT = 1;
+ private static final int TEXT_BOLD_BOTH = 2;
private float mTextsize;
private int mTextSelectColor;
private int mTextUnselectColor;
- private boolean mTextBold;
+ private int mTextBold;
private boolean mTextAllCaps;
private int mBarColor;
@@ -143,7 +146,7 @@ private void obtainAttributes(Context context, AttributeSet attrs) {
mTextsize = ta.getDimension(R.styleable.SegmentTabLayout_tl_textsize, sp2px(13f));
mTextSelectColor = ta.getColor(R.styleable.SegmentTabLayout_tl_textSelectColor, Color.parseColor("#ffffff"));
mTextUnselectColor = ta.getColor(R.styleable.SegmentTabLayout_tl_textUnselectColor, mIndicatorColor);
- mTextBold = ta.getBoolean(R.styleable.SegmentTabLayout_tl_textBold, false);
+ mTextBold = ta.getInt(R.styleable.SegmentTabLayout_tl_textBold, TEXT_BOLD_NONE);
mTextAllCaps = ta.getBoolean(R.styleable.SegmentTabLayout_tl_textAllCaps, false);
mTabSpaceEqual = ta.getBoolean(R.styleable.SegmentTabLayout_tl_tab_space_equal, true);
@@ -231,8 +234,10 @@ private void updateTabStyles() {
tv_tab_title.setText(tv_tab_title.getText().toString().toUpperCase());
}
- if (mTextBold) {
- tv_tab_title.getPaint().setFakeBoldText(mTextBold);
+ if (mTextBold == TEXT_BOLD_BOTH) {
+ tv_tab_title.getPaint().setFakeBoldText(true);
+ } else if (mTextBold == TEXT_BOLD_NONE) {
+ tv_tab_title.getPaint().setFakeBoldText(false);
}
}
}
@@ -243,6 +248,9 @@ private void updateTabSelection(int position) {
final boolean isSelect = i == position;
TextView tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
tab_title.setTextColor(isSelect ? mTextSelectColor : mTextUnselectColor);
+ if (mTextBold == TEXT_BOLD_WHEN_SELECT) {
+ tab_title.getPaint().setFakeBoldText(isSelect);
+ }
}
}
@@ -488,7 +496,7 @@ public void setTextUnselectColor(int textUnselectColor) {
updateTabStyles();
}
- public void setTextBold(boolean textBold) {
+ public void setTextBold(int textBold) {
this.mTextBold = textBold;
updateTabStyles();
}
@@ -582,7 +590,7 @@ public int getTextUnselectColor() {
return mTextUnselectColor;
}
- public boolean isTextBold() {
+ public int getTextBold() {
return mTextBold;
}
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 a2924f37..31ea2599 100644
--- a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SlidingTabLayout.java
+++ b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SlidingTabLayout.java
@@ -84,10 +84,13 @@ public class SlidingTabLayout extends HorizontalScrollView implements ViewPager.
private float mDividerPadding;
/** title */
+ private static final int TEXT_BOLD_NONE = 0;
+ private static final int TEXT_BOLD_WHEN_SELECT = 1;
+ private static final int TEXT_BOLD_BOTH = 2;
private float mTextsize;
private int mTextSelectColor;
private int mTextUnselectColor;
- private boolean mTextBold;
+ private int mTextBold;
private boolean mTextAllCaps;
private int mLastScrollX;
@@ -155,7 +158,7 @@ private void obtainAttributes(Context context, AttributeSet attrs) {
mTextsize = ta.getDimension(R.styleable.SlidingTabLayout_tl_textsize, sp2px(14));
mTextSelectColor = ta.getColor(R.styleable.SlidingTabLayout_tl_textSelectColor, Color.parseColor("#ffffff"));
mTextUnselectColor = ta.getColor(R.styleable.SlidingTabLayout_tl_textUnselectColor, Color.parseColor("#AAffffff"));
- mTextBold = ta.getBoolean(R.styleable.SlidingTabLayout_tl_textBold, false);
+ mTextBold = ta.getInt(R.styleable.SlidingTabLayout_tl_textBold, TEXT_BOLD_NONE);
mTextAllCaps = ta.getBoolean(R.styleable.SlidingTabLayout_tl_textAllCaps, false);
mTabSpaceEqual = ta.getBoolean(R.styleable.SlidingTabLayout_tl_tab_space_equal, false);
@@ -296,8 +299,10 @@ private void updateTabStyles() {
tv_tab_title.setText(tv_tab_title.getText().toString().toUpperCase());
}
- if (mTextBold) {
- tv_tab_title.getPaint().setFakeBoldText(mTextBold);
+ if (mTextBold == TEXT_BOLD_BOTH) {
+ tv_tab_title.getPaint().setFakeBoldText(true);
+ } else if (mTextBold == TEXT_BOLD_NONE) {
+ tv_tab_title.getPaint().setFakeBoldText(false);
}
}
}
@@ -359,6 +364,9 @@ private void updateTabSelection(int position) {
if (tab_title != null) {
tab_title.setTextColor(isSelect ? mTextSelectColor : mTextUnselectColor);
+ if (mTextBold == TEXT_BOLD_WHEN_SELECT) {
+ tab_title.getPaint().setFakeBoldText(isSelect);
+ }
}
}
}
@@ -514,6 +522,12 @@ protected void onDraw(Canvas canvas) {
public void setCurrentTab(int currentTab) {
this.mCurrentTab = currentTab;
mViewPager.setCurrentItem(currentTab);
+
+ }
+
+ public void setCurrentTab(int currentTab, boolean smoothScroll) {
+ this.mCurrentTab = currentTab;
+ mViewPager.setCurrentItem(currentTab, smoothScroll);
}
public void setIndicatorStyle(int indicatorStyle) {
@@ -620,7 +634,7 @@ public void setTextUnselectColor(int textUnselectColor) {
updateTabStyles();
}
- public void setTextBold(boolean textBold) {
+ public void setTextBold(int textBold) {
this.mTextBold = textBold;
updateTabStyles();
}
@@ -719,7 +733,7 @@ public int getTextUnselectColor() {
return mTextUnselectColor;
}
- public boolean isTextBold() {
+ public int getTextBold() {
return mTextBold;
}
diff --git a/FlycoTabLayout_Lib/src/main/res/values/attrs.xml b/FlycoTabLayout_Lib/src/main/res/values/attrs.xml
index 6949bd01..b0afdbee 100644
--- a/FlycoTabLayout_Lib/src/main/res/values/attrs.xml
+++ b/FlycoTabLayout_Lib/src/main/res/values/attrs.xml
@@ -69,7 +69,11 @@
-
+
+
+
+
+
diff --git a/README.md b/README.md
index e86925ce..2c790e89 100644
--- a/README.md
+++ b/README.md
@@ -69,7 +69,7 @@ dependencies{
After v2.0.2(support 3.0+)
dependencies{
compile 'com.android.support:support-v4:23.1.1'
- compile 'com.flyco.tablayout:FlycoTabLayout_Lib:2.0.6@aar'
+ compile 'com.flyco.tablayout:FlycoTabLayout_Lib:2.0.8@aar'
}
```
diff --git a/README_CN.md b/README_CN.md
index 8e90d4cc..419d1fa7 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -67,7 +67,7 @@ dependencies{
After v2.0.2(support 3.0+)
dependencies{
compile 'com.android.support:support-v4:23.1.1'
- compile 'com.flyco.tablayout:FlycoTabLayout_Lib:2.0.6@aar'
+ compile 'com.flyco.tablayout:FlycoTabLayout_Lib:2.0.8@aar'
}
```
diff --git a/app/build.gradle b/app/build.gradle
index e155af85..a9f79410 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -25,7 +25,7 @@ dependencies {
compile project(':FlycoTabLayout_Lib')
//--->support 3.0+
-// compile 'com.flyco.tablayout:FlycoTabLayout_Lib:2.0.6@aar'
+// compile 'com.flyco.tablayout:FlycoTabLayout_Lib:2.0.8@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/res/layout/activity_common_tab.xml b/app/src/main/res/layout/activity_common_tab.xml
index d4b10f84..c5108466 100644
--- a/app/src/main/res/layout/activity_common_tab.xml
+++ b/app/src/main/res/layout/activity_common_tab.xml
@@ -75,10 +75,12 @@
android:layout_height="48dp"
android:background="#F6CE59"
tl:tl_iconVisible="false"
+ tl:tl_textBold="SELECT"
tl:tl_indicator_width="10dp"
tl:tl_textsize="14sp"/>
+ tl:tl_indicator_margin_top="2dp"
+ tl:tl_textBold="SELECT"/>
+ tl:tl_tab_width="80dp"
+ tl:tl_textBold="BOTH"/>
@@ -52,7 +53,7 @@
android:layout_height="48dp"
android:background="#3F9FE0"
tl:tl_textAllCaps="true"
- tl:tl_textBold="true"
+ tl:tl_textBold="BOTH"
tl:tl_textsize="14sp"/>