diff --git a/ChangeLogs.md b/ChangeLogs.md index 9d58cbb..fd94a02 100644 --- a/ChangeLogs.md +++ b/ChangeLogs.md @@ -1,3 +1,9 @@ +**v1.1.9** +- Add attribute 'strokeColor' +- Add attribute 'selectedTextColor' +- Add attribute 'unSelectedTextColor' + + **v1.1.8** - support setEnable - support attr 'disableColor' diff --git a/README.md b/README.md index 6870388..0275239 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,9 @@ A smart switchable button,support multiple tabs. CLICK THE ***STAR*** if it's u | strokeWidth | dimension | app:strokeWidth="2dp" | | textSize | dimension | app:textSize="16sp" | | selectedColor | color/reference | app:selectedColor="@color/red" | +| strokeColor | color/reference | app:strokeColor="@color/red" | +| selectedTextColor | color/reference | app:selectedTextColor="@color/red" | +| unSelectedTextColor | color/reference | app:unSelectedTextColor="@color/red" | | disableColor | color/reference | app:selectedColor="@color/gray" | | selectedTab | integer | app:selectedTab="1" | | switchTabs | reference | app:switchTabs="@array/switch_tabs" | @@ -18,7 +21,7 @@ A smart switchable button,support multiple tabs. CLICK THE ***STAR*** if it's u ![](https://github.com/KingJA/SwitchButton/blob/master/img/mark.png) ## Gradle ```xml - compile 'lib.kingja.switchbutton:switchbutton:1.1.8' + implementation 'com.github.hamzaahmedkhan:SwitchButton:v2.0.0' ``` ## Usage @@ -32,6 +35,9 @@ A smart switchable button,support multiple tabs. CLICK THE ***STAR*** if it's u app:strokeWidth="1dp" app:selectedTab="0" app:selectedColor="#eb7b00" + app:selectedTextColor="#ffffff" + app:strokeColor="#ffffff" + app:unSelectedTextColor="#ffffff" app:switchTabs="@array/switch_tabs" app:typeface="DeVinneTxtBT.ttf" app:textSize="14sp" /> diff --git a/gradle.properties b/gradle.properties index da4b76e..ba7f24c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=1.1.8 +VERSION_NAME=1.1.9 VERSION_CODE=2019011001 COMPILE_SDK_VERSION = 27 BUILD_TOOLS_VERSION = 27.0.3 diff --git a/libk-switchbutton/build.gradle b/libk-switchbutton/build.gradle index 3eb925e..c9df5ac 100644 --- a/libk-switchbutton/build.gradle +++ b/libk-switchbutton/build.gradle @@ -29,7 +29,7 @@ publish { artifactId = 'switchbutton' userOrg = 'kingja' groupId = 'lib.kingja.switchbutton' - publishVersion = '1.1.8' + publishVersion = '1.1.9' desc = 'A smart switchable button,support multiple tabs.' website = 'https://github.com/KingJA/SwitchButton' } diff --git a/libk-switchbutton/src/main/java/lib/kingja/switchbutton/SwitchMultiButton.java b/libk-switchbutton/src/main/java/lib/kingja/switchbutton/SwitchMultiButton.java index cac9e9f..c3a7504 100644 --- a/libk-switchbutton/src/main/java/lib/kingja/switchbutton/SwitchMultiButton.java +++ b/libk-switchbutton/src/main/java/lib/kingja/switchbutton/SwitchMultiButton.java @@ -63,6 +63,9 @@ public class SwitchMultiButton extends View { private float mStrokeRadius; private float mStrokeWidth; private int mSelectedColor; + private int mStrokeColor; + private int mSelectedTextColor; + private int mUnSelectedTextColor; private int mDisableColor; private float mTextSize; private int mSelectedTab; @@ -99,6 +102,9 @@ private void initAttrs(Context context, AttributeSet attrs) { mStrokeWidth = typedArray.getDimension(R.styleable.SwitchMultiButton_strokeWidth, STROKE_WIDTH); mTextSize = typedArray.getDimension(R.styleable.SwitchMultiButton_textSize, TEXT_SIZE); mSelectedColor = typedArray.getColor(R.styleable.SwitchMultiButton_selectedColor, SELECTED_COLOR); + mStrokeColor = typedArray.getColor(R.styleable.SwitchMultiButton_strokeColor, SELECTED_COLOR); + mSelectedTextColor = typedArray.getColor(R.styleable.SwitchMultiButton_selectedTextColor, SELECTED_COLOR); + mUnSelectedTextColor = typedArray.getColor(R.styleable.SwitchMultiButton_unSelectedTextColor, SELECTED_COLOR); mDisableColor = typedArray.getColor(R.styleable.SwitchMultiButton_disableColor, DISABLE_COLOR); mSelectedTab = typedArray.getInteger(R.styleable.SwitchMultiButton_selectedTab, SELECTED_TAB); String mTypeface = typedArray.getString(R.styleable.SwitchMultiButton_typeface); @@ -119,7 +125,7 @@ private void initAttrs(Context context, AttributeSet attrs) { private void initPaint() { // round rectangle paint mStrokePaint = new Paint(); - mStrokePaint.setColor(mSelectedColor); + mStrokePaint.setColor(mStrokeColor); mStrokePaint.setStyle(Paint.Style.STROKE); mStrokePaint.setAntiAlias(true); mStrokePaint.setStrokeWidth(mStrokeWidth); @@ -131,12 +137,12 @@ private void initPaint() { // selected text paint mSelectedTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); mSelectedTextPaint.setTextSize(mTextSize); - mSelectedTextPaint.setColor(0xffffffff); + mSelectedTextPaint.setColor(mSelectedTextColor); mStrokePaint.setAntiAlias(true); // unselected text paint mUnselectedTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); mUnselectedTextPaint.setTextSize(mTextSize); - mUnselectedTextPaint.setColor(mSelectedColor); + mUnselectedTextPaint.setColor(mUnSelectedTextColor); mStrokePaint.setAntiAlias(true); mTextHeightOffset = -(mSelectedTextPaint.ascent() + mSelectedTextPaint.descent()) * 0.5f; mFontMetrics = mSelectedTextPaint.getFontMetrics(); @@ -427,6 +433,9 @@ protected Parcelable onSaveInstanceState() { bundle.putFloat("StrokeWidth", mStrokeWidth); bundle.putFloat("TextSize", mTextSize); bundle.putInt("SelectedColor", mSelectedColor); + bundle.putInt("StrokeColor", mStrokeColor); + bundle.putInt("SelectedTextColor", mSelectedTextColor); + bundle.putInt("UnSelectedTextColor", mUnSelectedTextColor); bundle.putInt("DisableColor", mDisableColor); bundle.putInt("SelectedTab", mSelectedTab); bundle.putBoolean("Enable", mEnable); @@ -441,6 +450,9 @@ protected void onRestoreInstanceState(Parcelable state) { mStrokeWidth = bundle.getFloat("StrokeWidth"); mTextSize = bundle.getFloat("TextSize"); mSelectedColor = bundle.getInt("SelectedColor"); + mStrokeColor = bundle.getInt("StrokeColor"); + mSelectedTextColor = bundle.getInt("SelectedTextColor"); + mUnSelectedTextColor = bundle.getInt("UnSelectedTextColor"); mDisableColor = bundle.getInt("DisableColor"); mSelectedTab = bundle.getInt("SelectedTab"); mEnable = bundle.getBoolean("Enable"); diff --git a/libk-switchbutton/src/main/res/values/attr.xml b/libk-switchbutton/src/main/res/values/attr.xml index 37ea8a9..b7f7055 100644 --- a/libk-switchbutton/src/main/res/values/attr.xml +++ b/libk-switchbutton/src/main/res/values/attr.xml @@ -3,6 +3,9 @@ + + +