6 | * 常量都在这边定义
7 | */
8 |
9 | public class Constant {
10 |
11 | // 整个库支持的五种状态
12 | public static final int[] STATE_0_UNABLE = {-android.R.attr.state_enabled};
13 | public static final int[] STATE_1_PRESSED = {android.R.attr.state_pressed};
14 | public static final int[] STATE_2_SELECTED = {android.R.attr.state_selected};
15 | public static final int[] STATE_3_CHECKED = {android.R.attr.state_checked};
16 | public static final int[] STATE_4_ENABLED = {android.R.attr.state_enabled};
17 | public static final int[] STATE_5_NONE = {};
18 |
19 | // 整个库支持的五种状态
20 | public static final int STATE_INDEX_COUNT = 5;
21 | public static final int STATE_INDEX_NORMAL = 0;
22 | public static final int STATE_INDEX_PRESSED = 1;
23 | public static final int STATE_INDEX_SELECTED = 2;
24 | public static final int STATE_INDEX_CHECKED = 3;
25 | public static final int STATE_INDEX_UNABLE = 4;
26 |
27 | // 整个库支持的五种状态
28 | public static final int[][] STATE_ARRAY = {STATE_0_UNABLE, STATE_1_PRESSED, STATE_2_SELECTED, STATE_3_CHECKED, STATE_4_ENABLED, STATE_5_NONE};
29 |
30 | // 渐变支持八个方向
31 | public static final int GRADIENT_ORIENTATION_T_B = 1;
32 | public static final int GRADIENT_ORIENTATION_TR_BL = 2;
33 | public static final int GRADIENT_ORIENTATION_R_L = 3;
34 | public static final int GRADIENT_ORIENTATION_BR_TL = 4;
35 | public static final int GRADIENT_ORIENTATION_B_T = 5;
36 | public static final int GRADIENT_ORIENTATION_BL_TR = 6;
37 | public static final int GRADIENT_ORIENTATION_L_R = 7;
38 | public static final int GRADIENT_ORIENTATION_TL_BR = 8;
39 |
40 | // 渐变支持3种类型
41 | public static final int GRADIENT_TYPE_NONE = 0;
42 | public static final int GRADIENT_TYPE_LINEAR = 1;
43 | public static final int GRADIENT_TYPE_RADIAL = 2;
44 | public static final int GRADIENT_TYPE_SWEEP = 3;
45 |
46 | // 默认从中间开始
47 | public static final float CENTER_XY = 0.5f;
48 | }
49 |
--------------------------------------------------------------------------------
/ColorViewLib/src/main/java/com/wei/android/lib/colorview/view/ColorButton.java:
--------------------------------------------------------------------------------
1 | package com.wei.android.lib.colorview.view;
2 |
3 | import android.content.Context;
4 | import android.content.res.ColorStateList;
5 | import android.content.res.TypedArray;
6 | import android.graphics.drawable.Drawable;
7 | import android.util.AttributeSet;
8 |
9 | import androidx.annotation.ColorInt;
10 | import androidx.annotation.DrawableRes;
11 | import androidx.appcompat.widget.AppCompatButton;
12 |
13 | import com.wei.android.lib.colorview.R;
14 | import com.wei.android.lib.colorview.helper.ColorTextViewHelper;
15 |
16 | /**
17 | * Created by UCCMAWEI on 2017/11/17.
18 | */
19 |
20 | public class ColorButton extends AppCompatButton {
21 |
22 | private ColorTextViewHelper mColorTextViewHelper;
23 |
24 | public ColorButton(Context context) {
25 | super(context);
26 | init(null);
27 | }
28 |
29 | public ColorButton(Context context, AttributeSet attrs) {
30 | super(context, attrs);
31 | init(attrs);
32 | }
33 |
34 | public ColorButton(Context context, AttributeSet attrs, int defStyleAttr) {
35 | super(context, attrs, defStyleAttr);
36 | init(attrs);
37 | }
38 |
39 | private void init(AttributeSet attrs) {
40 | TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ColorButton);
41 |
42 | mColorTextViewHelper = new ColorTextViewHelper(this,
43 | typedArray,
44 |
45 | getCurrentTextColor(),
46 | R.styleable.ColorButton_textColorNormal,
47 | R.styleable.ColorButton_textColorPressed,
48 | R.styleable.ColorButton_textColorSelected,
49 | R.styleable.ColorButton_textColorChecked,
50 | R.styleable.ColorButton_textColorUnable,
51 |
52 | R.styleable.ColorButton_textStrokeWidth,
53 |
54 | getCurrentHintTextColor(),
55 | R.styleable.ColorButton_textColorHintNormal,
56 | R.styleable.ColorButton_textColorHintPressed,
57 | R.styleable.ColorButton_textColorHintSelected,
58 | R.styleable.ColorButton_textColorHintChecked,
59 | R.styleable.ColorButton_textColorHintUnable,
60 |
61 | R.styleable.ColorButton_backgroundColorNormal,
62 | R.styleable.ColorButton_backgroundColorPressed,
63 | R.styleable.ColorButton_backgroundColorSelected,
64 | R.styleable.ColorButton_backgroundColorChecked,
65 | R.styleable.ColorButton_backgroundColorUnable,
66 |
67 | R.styleable.ColorButton_backgroundDrawableNormal,
68 | R.styleable.ColorButton_backgroundDrawablePressed,
69 | R.styleable.ColorButton_backgroundDrawableSelected,
70 | R.styleable.ColorButton_backgroundDrawableChecked,
71 | R.styleable.ColorButton_backgroundDrawableUnable,
72 |
73 | R.styleable.ColorButton_gradientOrientationNormal,
74 | R.styleable.ColorButton_gradientOrientationPressed,
75 | R.styleable.ColorButton_gradientOrientationSelected,
76 | R.styleable.ColorButton_gradientOrientationChecked,
77 | R.styleable.ColorButton_gradientOrientationUnable,
78 |
79 | R.styleable.ColorButton_gradientCenterXNormal,
80 | R.styleable.ColorButton_gradientCenterXPressed,
81 | R.styleable.ColorButton_gradientCenterXSelected,
82 | R.styleable.ColorButton_gradientCenterXChecked,
83 | R.styleable.ColorButton_gradientCenterXUnable,
84 |
85 | R.styleable.ColorButton_gradientCenterYNormal,
86 | R.styleable.ColorButton_gradientCenterYPressed,
87 | R.styleable.ColorButton_gradientCenterYSelected,
88 | R.styleable.ColorButton_gradientCenterYChecked,
89 | R.styleable.ColorButton_gradientCenterYUnable,
90 |
91 | R.styleable.ColorButton_gradientStartColorNormal,
92 | R.styleable.ColorButton_gradientStartColorPressed,
93 | R.styleable.ColorButton_gradientStartColorSelected,
94 | R.styleable.ColorButton_gradientStartColorChecked,
95 | R.styleable.ColorButton_gradientStartColorUnable,
96 |
97 | R.styleable.ColorButton_gradientCenterColorNormal,
98 | R.styleable.ColorButton_gradientCenterColorPressed,
99 | R.styleable.ColorButton_gradientCenterColorSelected,
100 | R.styleable.ColorButton_gradientCenterColorChecked,
101 | R.styleable.ColorButton_gradientCenterColorUnable,
102 |
103 | R.styleable.ColorButton_gradientEndColorNormal,
104 | R.styleable.ColorButton_gradientEndColorPressed,
105 | R.styleable.ColorButton_gradientEndColorSelected,
106 | R.styleable.ColorButton_gradientEndColorChecked,
107 | R.styleable.ColorButton_gradientEndColorUnable,
108 |
109 | R.styleable.ColorButton_gradientRadiusNormal,
110 | R.styleable.ColorButton_gradientRadiusPressed,
111 | R.styleable.ColorButton_gradientRadiusSelected,
112 | R.styleable.ColorButton_gradientRadiusChecked,
113 | R.styleable.ColorButton_gradientRadiusUnable,
114 |
115 | R.styleable.ColorButton_gradientTypeNormal,
116 | R.styleable.ColorButton_gradientTypePressed,
117 | R.styleable.ColorButton_gradientTypeSelected,
118 | R.styleable.ColorButton_gradientTypeChecked,
119 | R.styleable.ColorButton_gradientTypeUnable,
120 |
121 | R.styleable.ColorButton_cornerRadiusNormal,
122 | R.styleable.ColorButton_cornerRadiusPressed,
123 | R.styleable.ColorButton_cornerRadiusSelected,
124 | R.styleable.ColorButton_cornerRadiusChecked,
125 | R.styleable.ColorButton_cornerRadiusUnable,
126 |
127 | R.styleable.ColorButton_cornerRadiusTopLeftNormal,
128 | R.styleable.ColorButton_cornerRadiusTopLeftPressed,
129 | R.styleable.ColorButton_cornerRadiusTopLeftSelected,
130 | R.styleable.ColorButton_cornerRadiusTopLeftChecked,
131 | R.styleable.ColorButton_cornerRadiusTopLeftUnable,
132 |
133 | R.styleable.ColorButton_cornerRadiusTopRightNormal,
134 | R.styleable.ColorButton_cornerRadiusTopRightPressed,
135 | R.styleable.ColorButton_cornerRadiusTopRightSelected,
136 | R.styleable.ColorButton_cornerRadiusTopRightChecked,
137 | R.styleable.ColorButton_cornerRadiusTopRightUnable,
138 |
139 | R.styleable.ColorButton_cornerRadiusBottomLeftNormal,
140 | R.styleable.ColorButton_cornerRadiusBottomLeftPressed,
141 | R.styleable.ColorButton_cornerRadiusBottomLeftSelected,
142 | R.styleable.ColorButton_cornerRadiusBottomLeftChecked,
143 | R.styleable.ColorButton_cornerRadiusBottomLeftUnable,
144 |
145 | R.styleable.ColorButton_cornerRadiusBottomRightNormal,
146 | R.styleable.ColorButton_cornerRadiusBottomRightPressed,
147 | R.styleable.ColorButton_cornerRadiusBottomRightSelected,
148 | R.styleable.ColorButton_cornerRadiusBottomRightChecked,
149 | R.styleable.ColorButton_cornerRadiusBottomRightUnable,
150 |
151 | R.styleable.ColorButton_borderWidthNormal,
152 | R.styleable.ColorButton_borderWidthPressed,
153 | R.styleable.ColorButton_borderWidthSelected,
154 | R.styleable.ColorButton_borderWidthChecked,
155 | R.styleable.ColorButton_borderWidthUnable,
156 |
157 | R.styleable.ColorButton_borderDashWidthNormal,
158 | R.styleable.ColorButton_borderDashWidthPressed,
159 | R.styleable.ColorButton_borderDashWidthSelected,
160 | R.styleable.ColorButton_borderDashWidthChecked,
161 | R.styleable.ColorButton_borderDashWidthUnable,
162 |
163 | R.styleable.ColorButton_borderDashGapNormal,
164 | R.styleable.ColorButton_borderDashGapPressed,
165 | R.styleable.ColorButton_borderDashGapSelected,
166 | R.styleable.ColorButton_borderDashGapChecked,
167 | R.styleable.ColorButton_borderDashGapUnable,
168 |
169 | R.styleable.ColorButton_borderColorNormal,
170 | R.styleable.ColorButton_borderColorPressed,
171 | R.styleable.ColorButton_borderColorSelected,
172 | R.styleable.ColorButton_borderColorChecked,
173 | R.styleable.ColorButton_borderColorUnable,
174 |
175 | R.styleable.ColorButton_drawableLeftNormal,
176 | R.styleable.ColorButton_drawableLeftPressed,
177 | R.styleable.ColorButton_drawableLeftSelected,
178 | R.styleable.ColorButton_drawableLeftChecked,
179 | R.styleable.ColorButton_drawableLeftUnable,
180 |
181 | R.styleable.ColorButton_drawableTopNormal,
182 | R.styleable.ColorButton_drawableTopPressed,
183 | R.styleable.ColorButton_drawableTopSelected,
184 | R.styleable.ColorButton_drawableTopChecked,
185 | R.styleable.ColorButton_drawableTopUnable,
186 |
187 | R.styleable.ColorButton_drawableRightNormal,
188 | R.styleable.ColorButton_drawableRightPressed,
189 | R.styleable.ColorButton_drawableRightSelected,
190 | R.styleable.ColorButton_drawableRightChecked,
191 | R.styleable.ColorButton_drawableRightUnable,
192 |
193 | R.styleable.ColorButton_drawableBottomNormal,
194 | R.styleable.ColorButton_drawableBottomPressed,
195 | R.styleable.ColorButton_drawableBottomSelected,
196 | R.styleable.ColorButton_drawableBottomChecked,
197 | R.styleable.ColorButton_drawableBottomUnable,
198 |
199 | R.styleable.ColorButton_drawableLeftWidth,
200 | R.styleable.ColorButton_drawableLeftHeight,
201 |
202 | R.styleable.ColorButton_drawableTopWidth,
203 | R.styleable.ColorButton_drawableTopHeight,
204 |
205 | R.styleable.ColorButton_drawableRightWidth,
206 | R.styleable.ColorButton_drawableRightHeight,
207 |
208 | R.styleable.ColorButton_drawableBottomWidth,
209 | R.styleable.ColorButton_drawableBottomHeight,
210 |
211 | R.styleable.ColorButton_backgroundTintPressed);
212 |
213 | typedArray.recycle();
214 | }
215 |
216 | public ColorTextViewHelper getColorHelper() {
217 | return mColorTextViewHelper;
218 | }
219 |
220 | @Deprecated
221 | @Override
222 | public void setBackground(Drawable background) {
223 | super.setBackground(background);
224 | }
225 |
226 | @Deprecated
227 | @Override
228 | public void setBackgroundColor(@ColorInt int color) {
229 | super.setBackgroundColor(color);
230 | }
231 |
232 | @Deprecated
233 | @Override
234 | public void setBackgroundResource(@DrawableRes int resId) {
235 | super.setBackgroundResource(resId);
236 | }
237 |
238 | @Deprecated
239 | @Override
240 | public void setTextColor(@ColorInt int color) {
241 | super.setTextColor(color);
242 | }
243 |
244 | @Deprecated
245 | @Override
246 | public void setTextColor(ColorStateList colors) {
247 | super.setTextColor(colors);
248 | }
249 | }
250 |
--------------------------------------------------------------------------------
/ColorViewLib/src/main/java/com/wei/android/lib/colorview/view/ColorEditText.java:
--------------------------------------------------------------------------------
1 | package com.wei.android.lib.colorview.view;
2 |
3 | import android.content.Context;
4 | import android.content.res.ColorStateList;
5 | import android.content.res.TypedArray;
6 | import android.graphics.drawable.Drawable;
7 | import android.util.AttributeSet;
8 |
9 | import androidx.annotation.ColorInt;
10 | import androidx.annotation.DrawableRes;
11 | import androidx.appcompat.widget.AppCompatEditText;
12 |
13 | import com.wei.android.lib.colorview.R;
14 | import com.wei.android.lib.colorview.helper.ColorTextViewHelper;
15 |
16 | /**
17 | * Created by UCCMAWEI on 2017/11/17.
18 | */
19 |
20 | public class ColorEditText extends AppCompatEditText {
21 |
22 | private ColorTextViewHelper mColorTextViewHelper;
23 |
24 | public ColorEditText(Context context) {
25 | super(context);
26 | init(null);
27 | }
28 |
29 | public ColorEditText(Context context, AttributeSet attrs) {
30 | super(context, attrs);
31 | init(attrs);
32 | }
33 |
34 | public ColorEditText(Context context, AttributeSet attrs, int defStyleAttr) {
35 | super(context, attrs, defStyleAttr);
36 | init(attrs);
37 | }
38 |
39 | private void init(AttributeSet attrs) {
40 | TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ColorEditText);
41 |
42 | mColorTextViewHelper = new ColorTextViewHelper(this,
43 | typedArray,
44 |
45 | getCurrentTextColor(),
46 | R.styleable.ColorEditText_textColorNormal,
47 | R.styleable.ColorEditText_textColorPressed,
48 | R.styleable.ColorEditText_textColorSelected,
49 | R.styleable.ColorEditText_textColorChecked,
50 | R.styleable.ColorEditText_textColorUnable,
51 |
52 | R.styleable.ColorEditText_textStrokeWidth,
53 |
54 | getCurrentHintTextColor(),
55 | R.styleable.ColorEditText_textColorHintNormal,
56 | R.styleable.ColorEditText_textColorHintPressed,
57 | R.styleable.ColorEditText_textColorHintSelected,
58 | R.styleable.ColorEditText_textColorHintChecked,
59 | R.styleable.ColorEditText_textColorHintUnable,
60 |
61 | R.styleable.ColorEditText_backgroundColorNormal,
62 | R.styleable.ColorEditText_backgroundColorPressed,
63 | R.styleable.ColorEditText_backgroundColorSelected,
64 | R.styleable.ColorEditText_backgroundColorChecked,
65 | R.styleable.ColorEditText_backgroundColorUnable,
66 |
67 | R.styleable.ColorEditText_backgroundDrawableNormal,
68 | R.styleable.ColorEditText_backgroundDrawablePressed,
69 | R.styleable.ColorEditText_backgroundDrawableSelected,
70 | R.styleable.ColorEditText_backgroundDrawableChecked,
71 | R.styleable.ColorEditText_backgroundDrawableUnable,
72 |
73 | R.styleable.ColorEditText_gradientOrientationNormal,
74 | R.styleable.ColorEditText_gradientOrientationPressed,
75 | R.styleable.ColorEditText_gradientOrientationSelected,
76 | R.styleable.ColorEditText_gradientOrientationChecked,
77 | R.styleable.ColorEditText_gradientOrientationUnable,
78 |
79 | R.styleable.ColorEditText_gradientCenterXNormal,
80 | R.styleable.ColorEditText_gradientCenterXPressed,
81 | R.styleable.ColorEditText_gradientCenterXSelected,
82 | R.styleable.ColorEditText_gradientCenterXChecked,
83 | R.styleable.ColorEditText_gradientCenterXUnable,
84 |
85 | R.styleable.ColorEditText_gradientCenterYNormal,
86 | R.styleable.ColorEditText_gradientCenterYPressed,
87 | R.styleable.ColorEditText_gradientCenterYSelected,
88 | R.styleable.ColorEditText_gradientCenterYChecked,
89 | R.styleable.ColorEditText_gradientCenterYUnable,
90 |
91 | R.styleable.ColorEditText_gradientStartColorNormal,
92 | R.styleable.ColorEditText_gradientStartColorPressed,
93 | R.styleable.ColorEditText_gradientStartColorSelected,
94 | R.styleable.ColorEditText_gradientStartColorChecked,
95 | R.styleable.ColorEditText_gradientStartColorUnable,
96 |
97 | R.styleable.ColorEditText_gradientCenterColorNormal,
98 | R.styleable.ColorEditText_gradientCenterColorPressed,
99 | R.styleable.ColorEditText_gradientCenterColorSelected,
100 | R.styleable.ColorEditText_gradientCenterColorChecked,
101 | R.styleable.ColorEditText_gradientCenterColorUnable,
102 |
103 | R.styleable.ColorEditText_gradientEndColorNormal,
104 | R.styleable.ColorEditText_gradientEndColorPressed,
105 | R.styleable.ColorEditText_gradientEndColorSelected,
106 | R.styleable.ColorEditText_gradientEndColorChecked,
107 | R.styleable.ColorEditText_gradientEndColorUnable,
108 |
109 | R.styleable.ColorEditText_gradientRadiusNormal,
110 | R.styleable.ColorEditText_gradientRadiusPressed,
111 | R.styleable.ColorEditText_gradientRadiusSelected,
112 | R.styleable.ColorEditText_gradientRadiusChecked,
113 | R.styleable.ColorEditText_gradientRadiusUnable,
114 |
115 | R.styleable.ColorEditText_gradientTypeNormal,
116 | R.styleable.ColorEditText_gradientTypePressed,
117 | R.styleable.ColorEditText_gradientTypeSelected,
118 | R.styleable.ColorEditText_gradientTypeChecked,
119 | R.styleable.ColorEditText_gradientTypeUnable,
120 |
121 | R.styleable.ColorEditText_cornerRadiusNormal,
122 | R.styleable.ColorEditText_cornerRadiusPressed,
123 | R.styleable.ColorEditText_cornerRadiusSelected,
124 | R.styleable.ColorEditText_cornerRadiusChecked,
125 | R.styleable.ColorEditText_cornerRadiusUnable,
126 |
127 | R.styleable.ColorEditText_cornerRadiusTopLeftNormal,
128 | R.styleable.ColorEditText_cornerRadiusTopLeftPressed,
129 | R.styleable.ColorEditText_cornerRadiusTopLeftSelected,
130 | R.styleable.ColorEditText_cornerRadiusTopLeftChecked,
131 | R.styleable.ColorEditText_cornerRadiusTopLeftUnable,
132 |
133 | R.styleable.ColorEditText_cornerRadiusTopRightNormal,
134 | R.styleable.ColorEditText_cornerRadiusTopRightPressed,
135 | R.styleable.ColorEditText_cornerRadiusTopRightSelected,
136 | R.styleable.ColorEditText_cornerRadiusTopRightChecked,
137 | R.styleable.ColorEditText_cornerRadiusTopRightUnable,
138 |
139 | R.styleable.ColorEditText_cornerRadiusBottomLeftNormal,
140 | R.styleable.ColorEditText_cornerRadiusBottomLeftPressed,
141 | R.styleable.ColorEditText_cornerRadiusBottomLeftSelected,
142 | R.styleable.ColorEditText_cornerRadiusBottomLeftChecked,
143 | R.styleable.ColorEditText_cornerRadiusBottomLeftUnable,
144 |
145 | R.styleable.ColorEditText_cornerRadiusBottomRightNormal,
146 | R.styleable.ColorEditText_cornerRadiusBottomRightPressed,
147 | R.styleable.ColorEditText_cornerRadiusBottomRightSelected,
148 | R.styleable.ColorEditText_cornerRadiusBottomRightChecked,
149 | R.styleable.ColorEditText_cornerRadiusBottomRightUnable,
150 |
151 | R.styleable.ColorEditText_borderWidthNormal,
152 | R.styleable.ColorEditText_borderWidthPressed,
153 | R.styleable.ColorEditText_borderWidthSelected,
154 | R.styleable.ColorEditText_borderWidthChecked,
155 | R.styleable.ColorEditText_borderWidthUnable,
156 |
157 | R.styleable.ColorEditText_borderDashWidthNormal,
158 | R.styleable.ColorEditText_borderDashWidthPressed,
159 | R.styleable.ColorEditText_borderDashWidthSelected,
160 | R.styleable.ColorEditText_borderDashWidthChecked,
161 | R.styleable.ColorEditText_borderDashWidthUnable,
162 |
163 | R.styleable.ColorEditText_borderDashGapNormal,
164 | R.styleable.ColorEditText_borderDashGapPressed,
165 | R.styleable.ColorEditText_borderDashGapSelected,
166 | R.styleable.ColorEditText_borderDashGapChecked,
167 | R.styleable.ColorEditText_borderDashGapUnable,
168 |
169 | R.styleable.ColorEditText_borderColorNormal,
170 | R.styleable.ColorEditText_borderColorPressed,
171 | R.styleable.ColorEditText_borderColorSelected,
172 | R.styleable.ColorEditText_borderColorChecked,
173 | R.styleable.ColorEditText_borderColorUnable,
174 |
175 | R.styleable.ColorEditText_drawableLeftNormal,
176 | R.styleable.ColorEditText_drawableLeftPressed,
177 | R.styleable.ColorEditText_drawableLeftSelected,
178 | R.styleable.ColorEditText_drawableLeftChecked,
179 | R.styleable.ColorEditText_drawableLeftUnable,
180 |
181 | R.styleable.ColorEditText_drawableTopNormal,
182 | R.styleable.ColorEditText_drawableTopPressed,
183 | R.styleable.ColorEditText_drawableTopSelected,
184 | R.styleable.ColorEditText_drawableTopChecked,
185 | R.styleable.ColorEditText_drawableTopUnable,
186 |
187 | R.styleable.ColorEditText_drawableRightNormal,
188 | R.styleable.ColorEditText_drawableRightPressed,
189 | R.styleable.ColorEditText_drawableRightSelected,
190 | R.styleable.ColorEditText_drawableRightChecked,
191 | R.styleable.ColorEditText_drawableRightUnable,
192 |
193 | R.styleable.ColorEditText_drawableBottomNormal,
194 | R.styleable.ColorEditText_drawableBottomPressed,
195 | R.styleable.ColorEditText_drawableBottomSelected,
196 | R.styleable.ColorEditText_drawableBottomChecked,
197 | R.styleable.ColorEditText_drawableBottomUnable,
198 |
199 | R.styleable.ColorEditText_drawableLeftWidth,
200 | R.styleable.ColorEditText_drawableLeftHeight,
201 |
202 | R.styleable.ColorEditText_drawableTopWidth,
203 | R.styleable.ColorEditText_drawableTopHeight,
204 |
205 | R.styleable.ColorEditText_drawableRightWidth,
206 | R.styleable.ColorEditText_drawableRightHeight,
207 |
208 | R.styleable.ColorEditText_drawableBottomWidth,
209 | R.styleable.ColorEditText_drawableBottomHeight,
210 |
211 | R.styleable.ColorEditText_backgroundTintPressed);
212 |
213 | typedArray.recycle();
214 | }
215 |
216 | public ColorTextViewHelper getColorHelper() {
217 | return mColorTextViewHelper;
218 | }
219 |
220 | @Deprecated
221 | @Override
222 | public void setBackground(Drawable background) {
223 | super.setBackground(background);
224 | }
225 |
226 | @Deprecated
227 | @Override
228 | public void setBackgroundColor(@ColorInt int color) {
229 | super.setBackgroundColor(color);
230 | }
231 |
232 | @Deprecated
233 | @Override
234 | public void setBackgroundResource(@DrawableRes int resId) {
235 | super.setBackgroundResource(resId);
236 | }
237 |
238 | @Deprecated
239 | @Override
240 | public void setTextColor(@ColorInt int color) {
241 | super.setTextColor(color);
242 | }
243 |
244 | @Deprecated
245 | @Override
246 | public void setTextColor(ColorStateList colors) {
247 | super.setTextColor(colors);
248 | }
249 | }
250 |
--------------------------------------------------------------------------------
/ColorViewLib/src/main/java/com/wei/android/lib/colorview/view/ColorFrameLayout.java:
--------------------------------------------------------------------------------
1 | package com.wei.android.lib.colorview.view;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.drawable.Drawable;
6 | import android.os.Build;
7 | import android.util.AttributeSet;
8 | import android.view.View;
9 | import android.widget.FrameLayout;
10 |
11 | import androidx.annotation.ColorInt;
12 | import androidx.annotation.DrawableRes;
13 | import androidx.annotation.NonNull;
14 | import androidx.annotation.Nullable;
15 | import androidx.annotation.RequiresApi;
16 |
17 | import com.wei.android.lib.colorview.R;
18 | import com.wei.android.lib.colorview.helper.ColorViewHelper;
19 |
20 | /**
21 | * Created by UCCMAWEI on 2017/11/17.
22 | */
23 |
24 | public class ColorFrameLayout extends FrameLayout {
25 |
26 | private ColorViewHelper