Skip to content

Commit

Permalink
字体颜色修复
Browse files Browse the repository at this point in the history
  • Loading branch information
pichsy committed Jan 5, 2021
1 parent 0008db2 commit 4e95173
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ android {
dependencies {

implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.github.pichsy:xwidget:1.3'
// implementation 'com.github.pichsy:xwidget:1.3'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
// implementation project(':widget')
implementation project(':widget')
}
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:background="#F7F7C2"
android:textColor="#d00"
android:text="大河之剑天上来,飞流直下三千尺"
android:textSize="20sp"
android:textStyle="bold"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
public class XTextViewHelper implements XITextView {

private final WeakReference<TextView> mOwner;
private int normalColor = 0;
private int normalColor = Color.DKGRAY;
private int pressedColor = 0;
private int checkedColor = 0;
private int unEnabledColor = 0;
Expand Down Expand Up @@ -46,11 +46,11 @@ private void init(Context context, AttributeSet attrs, int defAttr, int defStyle
}
if (null != attrs || defAttr != 0 || defStyleRes != 0) {
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.XITextView, defAttr, defStyleRes);
normalColor = ta.getColor(R.styleable.XITextView_android_textColor, Color.LTGRAY);
pressedColor = ta.getColor(R.styleable.XITextView_xp_pressedTextColor, Color.LTGRAY);
checkedColor = ta.getColor(R.styleable.XITextView_xp_checkedTextColor, Color.LTGRAY);
unEnabledColor = ta.getColor(R.styleable.XITextView_xp_unEnabledTextColor, Color.LTGRAY);
activatedColor = ta.getColor(R.styleable.XITextView_xp_activatedTextColor, Color.LTGRAY);
normalColor = ta.getColor(R.styleable.XITextView_android_textColor, Color.DKGRAY);
pressedColor = ta.getColor(R.styleable.XITextView_xp_pressedTextColor, 0);
checkedColor = ta.getColor(R.styleable.XITextView_xp_checkedTextColor, 0);
unEnabledColor = ta.getColor(R.styleable.XITextView_xp_unEnabledTextColor, 0);
activatedColor = ta.getColor(R.styleable.XITextView_xp_activatedTextColor, 0);
isIgnoreGlobalTypeface = ta.getBoolean(R.styleable.XITextView_xp_ignoreGlobalTypeface, false);
ta.recycle();
setSelector();
Expand Down Expand Up @@ -104,6 +104,7 @@ private void setSelector() {
if (checkedColor != 0) {
builder.addPressedColor(checkedColor);
}
builder.setUnSateColor(normalColor);
mOwner.get().setTextColor(builder.build());
}
}
Expand Down

0 comments on commit 4e95173

Please sign in to comment.