Skip to content

Commit

Permalink
修复在点击事件里边设置setFakeBoldText()无效的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lygttpod committed Apr 21, 2019
1 parent 1aa88f3 commit 9c5e8f8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 28
versionCode 221
versionName "2.2.1"
versionCode 222
versionName "2.2.2"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

Expand Down
9 changes: 9 additions & 0 deletions library/src/main/java/com/allen/library/BaseTextView.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.text.TextUtils;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import android.widget.TextView;

/**
* Created by Allen on 2017/6/29.
Expand Down Expand Up @@ -162,6 +163,14 @@ public void setMaxEms(int topMaxEms, int centerMaxEms, int bottomMaxEms) {

}

public void setFakeBoldText(TextView textView, boolean isBold) {
if (textView != null) {
textView.getPaint().setFakeBoldText(isBold);
//在点击事件里边设置setFakeBoldText是无效的,必须调用invalidate刷新一下view
textView.invalidate();
}
}

public void setCenterSpaceHeight(int centerSpaceHeight) {
topTVParams.setMargins(0, 0, 0, centerSpaceHeight);
centerTVParams.setMargins(0, 0, 0, 0);
Expand Down
18 changes: 9 additions & 9 deletions library/src/main/java/com/allen/library/SuperTextView.java
Original file line number Diff line number Diff line change
Expand Up @@ -1622,7 +1622,7 @@ public SuperTextView setRightBottomTextColor(ColorStateList color) {
*/
public SuperTextView setLeftTopTextIsBold(boolean isBold) {
if (leftView != null) {
leftView.getTopTextView().getPaint().setFakeBoldText(isBold);
leftView.setFakeBoldText(leftView.getTopTextView(), isBold);
}
return this;
}
Expand All @@ -1634,7 +1634,7 @@ public SuperTextView setLeftTopTextIsBold(boolean isBold) {
*/
public SuperTextView setLeftTextIsBold(boolean isBold) {
if (leftView != null) {
leftView.getCenterTextView().getPaint().setFakeBoldText(isBold);
leftView.setFakeBoldText(leftView.getCenterTextView(), isBold);
}
return this;
}
Expand All @@ -1646,7 +1646,7 @@ public SuperTextView setLeftTextIsBold(boolean isBold) {
*/
public SuperTextView setLeftBottomTextIsBold(boolean isBold) {
if (leftView != null) {
leftView.getBottomTextView().getPaint().setFakeBoldText(isBold);
leftView.setFakeBoldText(leftView.getBottomTextView(), isBold);
}
return this;
}
Expand All @@ -1658,7 +1658,7 @@ public SuperTextView setLeftBottomTextIsBold(boolean isBold) {
*/
public SuperTextView setCenterTopTextIsBold(boolean isBold) {
if (centerView != null) {
centerView.getTopTextView().getPaint().setFakeBoldText(isBold);
centerView.setFakeBoldText(centerView.getTopTextView(), isBold);
}
return this;
}
Expand All @@ -1670,7 +1670,7 @@ public SuperTextView setCenterTopTextIsBold(boolean isBold) {
*/
public SuperTextView setCenterTextIsBold(boolean isBold) {
if (centerView != null) {
centerView.getCenterTextView().getPaint().setFakeBoldText(isBold);
centerView.setFakeBoldText(centerView.getCenterTextView(), isBold);
}
return this;
}
Expand All @@ -1682,7 +1682,7 @@ public SuperTextView setCenterTextIsBold(boolean isBold) {
*/
public SuperTextView setCenterBottomTextIsBold(boolean isBold) {
if (centerView != null) {
centerView.getBottomTextView().getPaint().setFakeBoldText(isBold);
centerView.setFakeBoldText(centerView.getBottomTextView(), isBold);
}
return this;
}
Expand All @@ -1694,7 +1694,7 @@ public SuperTextView setCenterBottomTextIsBold(boolean isBold) {
*/
public SuperTextView setRightTopTextIsBold(boolean isBold) {
if (rightView != null) {
rightView.getTopTextView().getPaint().setFakeBoldText(isBold);
rightView.setFakeBoldText(rightView.getTopTextView(), isBold);
}
return this;
}
Expand All @@ -1706,7 +1706,7 @@ public SuperTextView setRightTopTextIsBold(boolean isBold) {
*/
public SuperTextView setRightTextIsBold(boolean isBold) {
if (rightView != null) {
rightView.getCenterTextView().getPaint().setFakeBoldText(isBold);
rightView.setFakeBoldText(rightView.getCenterTextView(), isBold);
}
return this;
}
Expand All @@ -1718,7 +1718,7 @@ public SuperTextView setRightTextIsBold(boolean isBold) {
*/
public SuperTextView setRightBottomTextIsBold(boolean isBold) {
if (rightView != null) {
rightView.getBottomTextView().getPaint().setFakeBoldText(isBold);
rightView.setFakeBoldText(rightView.getBottomTextView(), isBold);
}
return this;
}
Expand Down

0 comments on commit 9c5e8f8

Please sign in to comment.