Skip to content

Commit

Permalink
Merge pull request #1 from H07000223/master
Browse files Browse the repository at this point in the history
sync
  • Loading branch information
309746069 authored Jul 27, 2016
2 parents 19278dd + 0a22c84 commit 029ad96
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 31 deletions.
5 changes: 5 additions & 0 deletions CHNAGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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')


6 changes: 2 additions & 4 deletions FlycoTabLayout_Lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ 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"

defaultConfig {
minSdkVersion 11
targetSdkVersion 23
versionCode 206
versionCode 208
versionName version
}
buildTypes {
Expand All @@ -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' // 项目的主页
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}
}

Expand Down Expand Up @@ -600,7 +608,7 @@ public void setTextUnselectColor(int textUnselectColor) {
updateTabStyles();
}

public void setTextBold(boolean textBold) {
public void setTextBold(int textBold) {
this.mTextBold = textBold;
updateTabStyles();
}
Expand Down Expand Up @@ -736,7 +744,7 @@ public int getTextUnselectColor() {
return mTextUnselectColor;
}

public boolean isTextBold() {
public int getTextBold() {
return mTextBold;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}
}
Expand All @@ -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);
}
}
}

Expand Down Expand Up @@ -488,7 +496,7 @@ public void setTextUnselectColor(int textUnselectColor) {
updateTabStyles();
}

public void setTextBold(boolean textBold) {
public void setTextBold(int textBold) {
this.mTextBold = textBold;
updateTabStyles();
}
Expand Down Expand Up @@ -582,7 +590,7 @@ public int getTextUnselectColor() {
return mTextUnselectColor;
}

public boolean isTextBold() {
public int getTextBold() {
return mTextBold;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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);
}
}
}
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -620,7 +634,7 @@ public void setTextUnselectColor(int textUnselectColor) {
updateTabStyles();
}

public void setTextBold(boolean textBold) {
public void setTextBold(int textBold) {
this.mTextBold = textBold;
updateTabStyles();
}
Expand Down Expand Up @@ -719,7 +733,7 @@ public int getTextUnselectColor() {
return mTextUnselectColor;
}

public boolean isTextBold() {
public int getTextBold() {
return mTextBold;
}

Expand Down
6 changes: 5 additions & 1 deletion FlycoTabLayout_Lib/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@
<!-- 设置字体未选中颜色 -->
<attr name="tl_textUnselectColor" format="color"/>
<!-- 设置字体加粗 -->
<attr name="tl_textBold" format="boolean"/>
<attr name="tl_textBold" format="enum">
<enum name="NONE" value="0"/>
<enum name="SELECT" value="1"/>
<enum name="BOTH" value="2"/>
</attr>
<!-- 设置字体全大写 -->
<attr name="tl_textAllCaps" format="boolean"/>

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
```
Expand Down
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
```

Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/layout/activity_common_tab.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>

<com.flyco.tablayout.CommonTabLayout
tl:tl_textBold="BOTH"
android:id="@+id/tl_5"
android:layout_width="match_parent"
android:layout_height="48dp"
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/res/layout/activity_segment_tab.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
tl:tl_indicator_margin_bottom="2dp"
tl:tl_indicator_margin_left="2dp"
tl:tl_indicator_margin_right="2dp"
tl:tl_indicator_margin_top="2dp"/>
tl:tl_indicator_margin_top="2dp"
tl:tl_textBold="SELECT"/>

<android.support.v4.view.ViewPager
android:id="@+id/vp_2"
Expand All @@ -68,7 +69,8 @@
tl:tl_indicator_margin_left="2dp"
tl:tl_indicator_margin_right="2dp"
tl:tl_indicator_margin_top="2dp"
tl:tl_tab_width="80dp"/>
tl:tl_tab_width="80dp"
tl:tl_textBold="BOTH"/>

<FrameLayout
android:id="@+id/fl_change"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/activity_sliding_tab.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
android:paddingBottom="15dp"
android:paddingTop="15dp"
tl:tl_indicator_gravity="TOP"
tl:tl_textBold="SELECT"
tl:tl_underline_color="#1A000000"
tl:tl_underline_gravity="TOP"
tl:tl_underline_height="1dp"/>
Expand Down Expand Up @@ -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"/>

<com.flyco.tablayout.SlidingTabLayout
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.android.tools.build:gradle:2.1.2'
// classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
// classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
// classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down

0 comments on commit 029ad96

Please sign in to comment.