diff --git a/app/build.gradle b/app/build.gradle index 360cb3f..af9835b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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') } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 52319e2..1db77c4 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -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" diff --git a/widget/src/main/java/com/pichs/common/widget/utils/XTextViewHelper.java b/widget/src/main/java/com/pichs/common/widget/utils/XTextViewHelper.java index 356603a..580cbf3 100644 --- a/widget/src/main/java/com/pichs/common/widget/utils/XTextViewHelper.java +++ b/widget/src/main/java/com/pichs/common/widget/utils/XTextViewHelper.java @@ -18,7 +18,7 @@ public class XTextViewHelper implements XITextView { private final WeakReference mOwner; - private int normalColor = 0; + private int normalColor = Color.DKGRAY; private int pressedColor = 0; private int checkedColor = 0; private int unEnabledColor = 0; @@ -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(); @@ -104,6 +104,7 @@ private void setSelector() { if (checkedColor != 0) { builder.addPressedColor(checkedColor); } + builder.setUnSateColor(normalColor); mOwner.get().setTextColor(builder.build()); } }