Skip to content

Commit 8434659

Browse files
committed
FixBug#118#121
1 parent 96539ad commit 8434659

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

library/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ android {
66
defaultConfig {
77
minSdkVersion 14
88
targetSdkVersion 31
9-
versionCode 16
10-
versionName "androidx.v0.0.13"
9+
versionCode 17
10+
versionName "androidx.v0.0.14"
1111
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1212
}
1313

library/src/main/java/com/ruffian/library/widget/helper/RBaseHelper.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@
2323
import android.view.ViewConfiguration;
2424
import android.view.ViewTreeObserver;
2525

26-
import androidx.annotation.ColorInt;
27-
import androidx.annotation.RequiresApi;
28-
import androidx.annotation.StyleableRes;
29-
import androidx.core.text.TextUtilsCompat;
30-
import androidx.core.view.ViewCompat;
31-
3226
import com.ruffian.library.widget.R;
3327
import com.ruffian.library.widget.clip.ClipHelper;
3428
import com.ruffian.library.widget.clip.ClipPathManager;
@@ -38,6 +32,12 @@
3832

3933
import java.util.Locale;
4034

35+
import androidx.annotation.ColorInt;
36+
import androidx.annotation.RequiresApi;
37+
import androidx.annotation.StyleableRes;
38+
import androidx.core.text.TextUtilsCompat;
39+
import androidx.core.view.ViewCompat;
40+
4141

4242
/**
4343
* BaseHelper
@@ -374,27 +374,27 @@ private void setupDefaultValue(boolean init) {
374374
if (mBackgroundColorNormalArray != null && mBackgroundColorNormalArray.length > 0) {
375375
mBackgroundNormal = setColors(mBackgroundNormal, mBackgroundColorNormalArray);
376376
} else {
377-
mBackgroundNormal.setColor(mBackgroundColorNormal);
377+
mBackgroundNormal = setColors(mBackgroundNormal, new int[]{mBackgroundColorNormal, mBackgroundColorNormal});
378378
}
379379
if (mBackgroundColorPressedArray != null && mBackgroundColorPressedArray.length > 0) {
380380
mBackgroundPressed = setColors(mBackgroundPressed, mBackgroundColorPressedArray);
381381
} else {
382-
mBackgroundPressed.setColor(mBackgroundColorPressed);
382+
mBackgroundPressed = setColors(mBackgroundPressed, new int[]{mBackgroundColorPressed, mBackgroundColorPressed});
383383
}
384384
if (mBackgroundColorUnableArray != null && mBackgroundColorUnableArray.length > 0) {
385385
mBackgroundUnable = setColors(mBackgroundUnable, mBackgroundColorUnableArray);
386386
} else {
387-
mBackgroundUnable.setColor(mBackgroundColorUnable);
387+
mBackgroundUnable = setColors(mBackgroundUnable, new int[]{mBackgroundColorUnable, mBackgroundColorUnable});
388388
}
389389
if (mBackgroundColorCheckedArray != null && mBackgroundColorCheckedArray.length > 0) {
390390
mBackgroundChecked = setColors(mBackgroundChecked, mBackgroundColorCheckedArray);
391391
} else {
392-
mBackgroundChecked.setColor(mBackgroundColorChecked);
392+
mBackgroundChecked = setColors(mBackgroundChecked, new int[]{mBackgroundColorChecked, mBackgroundColorChecked});
393393
}
394394
if (mBackgroundColorSelectedArray != null && mBackgroundColorSelectedArray.length > 0) {
395395
mBackgroundSelected = setColors(mBackgroundSelected, mBackgroundColorSelectedArray);
396396
} else {
397-
mBackgroundSelected.setColor(mBackgroundColorSelected);
397+
mBackgroundSelected = setColors(mBackgroundSelected, new int[]{mBackgroundColorSelected, mBackgroundColorSelected});
398398
}
399399

400400
//设置边框默认值

library/src/main/java/com/ruffian/library/widget/helper/RTextViewHelper.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
import android.view.MotionEvent;
1414
import android.widget.TextView;
1515

16-
import androidx.annotation.ColorInt;
17-
import androidx.annotation.StyleableRes;
18-
import androidx.appcompat.content.res.AppCompatResources;
19-
2016
import com.ruffian.library.widget.R;
2117
import com.ruffian.library.widget.iface.ITextViewFeature;
2218
import com.ruffian.library.widget.utils.TextViewUtils;
2319

20+
import androidx.annotation.ColorInt;
21+
import androidx.annotation.StyleableRes;
22+
import androidx.appcompat.content.res.AppCompatResources;
23+
2424
/**
2525
* TextView-Helper
2626
*
@@ -884,6 +884,7 @@ private void setSingleIconWithText() {
884884
if (translateX < 0) translateX = 0;
885885
//垂直方向计算
886886
float textHeight = TextViewUtils.get().getTextHeight(mView, drawableHeight, mPaddingTop, mPaddingBottom, drawablePaddingVertical);
887+
textHeight = Math.max(textHeight, Math.max(mIconHeightLeft, mIconHeightRight));//交叉轴存在icon时高度重新计算
887888
float bodyHeight = textHeight + drawableHeight + drawablePaddingVertical;//内容高度
888889
float actualHeight = mView.getHeight() - (mPaddingTop + mPaddingBottom);//实际可用高度
889890
int translateY = (int) (actualHeight - bodyHeight) / 2;
@@ -932,6 +933,7 @@ private void setMultipleIconWithText() {
932933
if (translateX < 0) translateX = 0;
933934
//垂直方向计算
934935
float textHeight = TextViewUtils.get().getTextHeight(mView, drawableHeightFinal, mPaddingTop, mPaddingBottom, drawablePaddingVerticalFinal);
936+
textHeight = Math.max(textHeight, Math.max(mIconHeightLeft, mIconHeightRight));//交叉轴存在icon时高度重新计算
935937
float bodyHeight = textHeight + drawableHeightFinal + drawablePaddingVerticalFinal;//内容高度
936938
float actualHeight = mView.getHeight() - (mPaddingTop + mPaddingBottom);//实际可用高度
937939
int translateY = (int) (actualHeight - bodyHeight) / 2;

0 commit comments

Comments
 (0)