constructor = clazz.getConstructor(int.class, int.class);
98 | return constructor.newInstance(width, height);
99 | } catch (Exception e) {
100 | System.err.print("控件无父容器,设置布局参数对象为ViewGroup.LayoutParams");
101 | return new ViewGroup.LayoutParams(width, height);
102 | }
103 | }
104 |
105 | /**
106 | * 设置指定控件的宽度
107 | *
108 | * @param view 要设置宽度的控件
109 | * @param width 控件的宽度要设置的值
110 | */
111 | public void setWidth(View view, float width) {
112 | if (view.getLayoutParams() == null)
113 | view.setLayoutParams(autoCreateLayoutParams(view, _ST.DP(width), 0));
114 | view.getLayoutParams().width = _ST.DP(width);
115 | }
116 |
117 | /**
118 | * 设置制定控件的高度
119 | *
120 | * @param view 要设置高度的控件
121 | * @param height 控件的高度要设置的值
122 | */
123 | public void setHeight(View view, float height) {
124 | if (view.getLayoutParams() == null)
125 | view.setLayoutParams(autoCreateLayoutParams(view, 0, _ST.DP(height)));
126 | view.getLayoutParams().height = _ST.DP(height);
127 | }
128 |
129 | /**
130 | * 设置控件的尺寸,单位DP
131 | *
132 | * @param view 要设置尺寸的控件
133 | * @param width 控件的宽度,单位DP
134 | * @param height 控件的高度,单位DP
135 | */
136 | public void setSize(View view, float width, float height) {
137 | setWidth(view, width);
138 | setHeight(view, height);
139 | }
140 |
141 | /**
142 | * 设置控件的尺寸,使用尺寸描述对象
143 | *
144 | * @param view 要设置尺寸的控件
145 | * @param size 控件的尺寸描述对象
146 | */
147 | public void setSize(View view, CGSize size) {
148 | setWidth(view, size.width);
149 | setHeight(view, size.height);
150 | }
151 |
152 | /**
153 | * 设置控件的矩形信息,使用矩形信息描述对象
154 | *
155 | * @param view 要设置控件矩形的控件
156 | * @param frame 控件的矩形信息描述对象
157 | */
158 | public void setFrame(View view, CGRect frame) {
159 | setSize(view, frame.size);
160 | setOrigin(view, frame.origin);
161 | }
162 | }
--------------------------------------------------------------------------------
/LemonSuperKit/lemonsuperkit/src/main/java/net/lemonsoft/lemonsuperkit/ui_kit/UIColor.java:
--------------------------------------------------------------------------------
1 | package net.lemonsoft.lemonsuperkit.ui_kit;
2 |
3 | import android.graphics.Color;
4 | import android.graphics.drawable.ColorDrawable;
5 | import android.graphics.drawable.Drawable;
6 | import android.graphics.drawable.ShapeDrawable;
7 |
8 | import net.lemonsoft.lemonsuperkit.core.graphics.CGColorRef;
9 | import net.lemonsoft.lemonsuperkit.native_ui.tools.LKColorTool;
10 |
11 | /**
12 | * LemonKit颜色描述对象
13 | * Created by LiuRi on 2016/12/29.
14 | */
15 |
16 | public class UIColor {
17 |
18 | private Drawable drawable;
19 |
20 | public Drawable getDrawable() {
21 | return drawable;
22 | }
23 |
24 | public UIColor(float red, float green, float blue, float alpha) {
25 | this.drawable = new ColorDrawable(
26 | LKColorTool.getDefaultColorTool().colorWithARGBFloat(alpha, red, green, blue)
27 | );
28 | }
29 |
30 | public UIColor(String hexColor) {
31 | this.drawable = new ColorDrawable(Color.parseColor(hexColor));
32 | }
33 |
34 | /**
35 | * 获取CGColor颜色值描述对象
36 | *
37 | * @return CGColor颜色值描述对象
38 | */
39 | public CGColorRef cgColor() {
40 | int colorValue = Color.argb(0, 255, 255, 255);
41 | if (drawable instanceof ColorDrawable)
42 | colorValue = ((ColorDrawable) drawable).getColor();
43 | else if (drawable instanceof ShapeDrawable)
44 | colorValue = ((ShapeDrawable) drawable).getPaint().getColor();
45 | return new CGColorRef(colorValue);
46 | }
47 |
48 | /**
49 | * 根据红绿蓝
50 | *
51 | * @param red 红色颜色值
52 | * @param green 绿色颜色值
53 | * @param blue 蓝色颜色值
54 | * @param alpha 透明度颜色值
55 | * @return 生成的UIColor对象
56 | */
57 | public static UIColor colorWithRedGreenBlueAlpha(float red, float green, float blue, float alpha) {
58 | return new UIColor(alpha, red, green, blue);
59 | }
60 |
61 | /**
62 | * 透明颜色
63 | * #00ffffff
64 | * 0,255,255,255
65 | */
66 | public static UIColor clearColor() {
67 | return new UIColor(1f, 1f, 1f, 0f);
68 | }
69 |
70 | /**
71 | * aliceblue
72 | * #f0f8ff
73 | * 240,248,255
74 | */
75 | public static UIColor aliceblueColor() {
76 | return new UIColor("#f0f8ff");
77 | }
78 |
79 | /**
80 | * antiquewhite
81 | * #faebd7
82 | * 250,235,215
83 | */
84 | public static UIColor antiquewhiteColor() {
85 | return new UIColor("#faebd7");
86 | }
87 |
88 | /**
89 | * aqua
90 | * #00ffff
91 | * 0,255,255
92 | */
93 | public static UIColor aquaColor() {
94 | return new UIColor("#00ffff");
95 | }
96 |
97 | /**
98 | * aquamarine
99 | * #7fffd4
100 | * 127,255,212
101 | */
102 | public static UIColor aquamarineColor() {
103 | return new UIColor("#7fffd4");
104 | }
105 |
106 | /**
107 | * azure
108 | * #f0ffff
109 | * 240,255,255
110 | */
111 | public static UIColor azureColor() {
112 | return new UIColor("#f0ffff");
113 | }
114 |
115 | /**
116 | * beige
117 | * #f5f5dc
118 | * 245,245,220
119 | */
120 | public static UIColor beigeColor() {
121 | return new UIColor("#f5f5dc");
122 | }
123 |
124 | /**
125 | * bisque
126 | * #ffe4c4
127 | * 255,228,196
128 | */
129 | public static UIColor bisqueColor() {
130 | return new UIColor("#ffe4c4");
131 | }
132 |
133 | /**
134 | * black
135 | * #000000
136 | * 0,0,0
137 | */
138 | public static UIColor blackColor() {
139 | return new UIColor("#000000");
140 | }
141 |
142 | /**
143 | * blanchedalmond
144 | * #ffebcd
145 | * 255,235,205
146 | */
147 | public static UIColor blanchedalmondColor() {
148 | return new UIColor("#ffebcd");
149 | }
150 |
151 | /**
152 | * blue
153 | * #0000ff
154 | * 0,0,255
155 | */
156 | public static UIColor blueColor() {
157 | return new UIColor("#0000ff");
158 | }
159 |
160 | /**
161 | * blueviolet
162 | * #8a2be2
163 | * 138,43,226
164 | */
165 | public static UIColor bluevioletColor() {
166 | return new UIColor("#8a2be2");
167 | }
168 |
169 | /**
170 | * brown
171 | * #a52a2a
172 | * 165,42,42
173 | */
174 | public static UIColor brownColor() {
175 | return new UIColor("#a52a2a");
176 | }
177 |
178 | /**
179 | * burlywood
180 | * #deb887
181 | * 222,184,135
182 | */
183 | public static UIColor burlywoodColor() {
184 | return new UIColor("#deb887");
185 | }
186 |
187 | /**
188 | * cadetblue
189 | * #5f9ea0
190 | * 95,158,160
191 | */
192 | public static UIColor cadetblueColor() {
193 | return new UIColor("#5f9ea0");
194 | }
195 |
196 | /**
197 | * chartruse
198 | * #7fff00
199 | * 127,255,0
200 | */
201 | public static UIColor chartruseColor() {
202 | return new UIColor("#7fff00");
203 | }
204 |
205 | /**
206 | * chocolate
207 | * #d2691e
208 | * 210,105,30
209 | */
210 | public static UIColor chocolateColor() {
211 | return new UIColor("#d2691e");
212 | }
213 |
214 | /**
215 | * coral
216 | * #ff7f50
217 | * 255,127,80
218 | */
219 | public static UIColor coralColor() {
220 | return new UIColor("#ff7f50");
221 | }
222 |
223 | /**
224 | * cornflowerblue
225 | * #6495ed
226 | * 100,149,237
227 | */
228 | public static UIColor cornflowerblueColor() {
229 | return new UIColor("#6495ed");
230 | }
231 |
232 | /**
233 | * cornsilk
234 | * #fff8dc
235 | * 255,248,220
236 | */
237 | public static UIColor cornsilkColor() {
238 | return new UIColor("#fff8dc");
239 | }
240 |
241 | /**
242 | * crimson
243 | * #dc143c
244 | * 220,20,60
245 | */
246 | public static UIColor crimsonColor() {
247 | return new UIColor("#dc143c");
248 | }
249 |
250 | /**
251 | * cyan
252 | * #00ffff
253 | * 0,255,255
254 | */
255 | public static UIColor cyanColor() {
256 | return new UIColor("#00ffff");
257 | }
258 |
259 | /**
260 | * darkblue
261 | * #00008b
262 | * 0,0,139
263 | */
264 | public static UIColor darkblueColor() {
265 | return new UIColor("#00008b");
266 | }
267 |
268 | /**
269 | * darkcyan
270 | * #008b8b
271 | * 0,139,139
272 | */
273 | public static UIColor darkcyanColor() {
274 | return new UIColor("#008b8b");
275 | }
276 |
277 | /**
278 | * darkgoldenrod
279 | * #b8860b
280 | * 184,134,11
281 | */
282 | public static UIColor darkgoldenrodColor() {
283 | return new UIColor("#b8860b");
284 | }
285 |
286 | /**
287 | * darkgray
288 | * #a9a9a9
289 | * 169,169,169
290 | */
291 | public static UIColor darkgrayColor() {
292 | return new UIColor("#a9a9a9");
293 | }
294 |
295 | /**
296 | * darkgreen
297 | * #006400
298 | * 0,100,0
299 | */
300 | public static UIColor darkgreenColor() {
301 | return new UIColor("#006400");
302 | }
303 |
304 | /**
305 | * darkkhaki
306 | * #bdb76b
307 | * 189,183,107
308 | */
309 | public static UIColor darkkhakiColor() {
310 | return new UIColor("#bdb76b");
311 | }
312 |
313 | /**
314 | * darkmagenta
315 | * #8b008b
316 | * 139,0,139
317 | */
318 | public static UIColor darkmagentaColor() {
319 | return new UIColor("#8b008b");
320 | }
321 |
322 | /**
323 | * darkolivegreen
324 | * #556b2f
325 | * 85,107,47
326 | */
327 | public static UIColor darkolivegreenColor() {
328 | return new UIColor("#556b2f");
329 | }
330 |
331 | /**
332 | * darkorange
333 | * #ff8c00
334 | * 255,140,0
335 | */
336 | public static UIColor darkorangeColor() {
337 | return new UIColor("#ff8c00");
338 | }
339 |
340 | /**
341 | * darkorchid
342 | * #9932cc
343 | * 153,50,204
344 | */
345 | public static UIColor darkorchidColor() {
346 | return new UIColor("#9932cc");
347 | }
348 |
349 | /**
350 | * darksalmon
351 | * #e9967a
352 | * 233,150,122
353 | */
354 | public static UIColor darksalmonColor() {
355 | return new UIColor("#e9967a");
356 | }
357 |
358 | /**
359 | * darkseagreen
360 | * #8fbc8f
361 | * 143,188,143
362 | */
363 | public static UIColor darkseagreenColor() {
364 | return new UIColor("#8fbc8f");
365 | }
366 |
367 | /**
368 | * darkslateblue
369 | * #483d8b
370 | * 72,61,139
371 | */
372 | public static UIColor darkslateblueColor() {
373 | return new UIColor("#483d8b");
374 | }
375 |
376 | /**
377 | * darkslategray
378 | * #2f4f4f
379 | * 47,79,79
380 | */
381 | public static UIColor darkslategrayColor() {
382 | return new UIColor("#2f4f4f");
383 | }
384 |
385 | /**
386 | * darkturquoise
387 | * #00ced1
388 | * 0,206,209
389 | */
390 | public static UIColor darkturquoiseColor() {
391 | return new UIColor("#00ced1");
392 | }
393 |
394 | /**
395 | * darkviolet
396 | * #9400d3
397 | * 148,0,211
398 | */
399 | public static UIColor darkvioletColor() {
400 | return new UIColor("#9400d3");
401 | }
402 |
403 | /**
404 | * deeppink
405 | * #ff1493
406 | * 255,20,147
407 | */
408 | public static UIColor deeppinkColor() {
409 | return new UIColor("#ff1493");
410 | }
411 |
412 | /**
413 | * deepskyblue
414 | * #00bfff
415 | * 0,191,255
416 | */
417 | public static UIColor deepskyblueColor() {
418 | return new UIColor("#00bfff");
419 | }
420 |
421 | /**
422 | * dimgray
423 | * #696969
424 | * 105,105,105
425 | */
426 | public static UIColor dimgrayColor() {
427 | return new UIColor("#696969");
428 | }
429 |
430 | /**
431 | * dodgerblue
432 | * #le90ff
433 | * 30,144,255
434 | */
435 | public static UIColor dodgerblueColor() {
436 | return new UIColor("#le90ff");
437 | }
438 |
439 | /**
440 | * firebrick
441 | * #b22222
442 | * 178,34,34
443 | */
444 | public static UIColor firebrickColor() {
445 | return new UIColor("#b22222");
446 | }
447 |
448 | /**
449 | * floralwhite
450 | * #fffaf0
451 | * 255,250,240
452 | */
453 | public static UIColor floralwhiteColor() {
454 | return new UIColor("#fffaf0");
455 | }
456 |
457 | /**
458 | * forestgreen
459 | * #228b22
460 | * 34,193,34
461 | */
462 | public static UIColor forestgreenColor() {
463 | return new UIColor("#228b22");
464 | }
465 |
466 | /**
467 | * fuchsia
468 | * #ff00ff
469 | * 255,0,255
470 | */
471 | public static UIColor fuchsiaColor() {
472 | return new UIColor("#ff00ff");
473 | }
474 |
475 | /**
476 | * gainsboro
477 | * #dcdcdc
478 | * 220,220,220
479 | */
480 | public static UIColor gainsboroColor() {
481 | return new UIColor("#dcdcdc");
482 | }
483 |
484 | /**
485 | * ghostwhite
486 | * #f8f8ff
487 | * 248,248,255
488 | */
489 | public static UIColor ghostwhiteColor() {
490 | return new UIColor("#f8f8ff");
491 | }
492 |
493 | /**
494 | * gold
495 | * #ffd700
496 | * 255,215,0
497 | */
498 | public static UIColor goldColor() {
499 | return new UIColor("#ffd700");
500 | }
501 |
502 | /**
503 | * goldenrod
504 | * #daa520
505 | * 218,165,32
506 | */
507 | public static UIColor goldenrodColor() {
508 | return new UIColor("#daa520");
509 | }
510 |
511 | /**
512 | * gray
513 | * #808080
514 | * 128,128,128
515 | */
516 | public static UIColor grayColor() {
517 | return new UIColor("#808080");
518 | }
519 |
520 | /**
521 | * green
522 | * #008000
523 | * 0,128,0
524 | */
525 | public static UIColor greenColor() {
526 | return new UIColor("#008000");
527 | }
528 |
529 | /**
530 | * greenyellow
531 | * #adff2f
532 | * 173,255,47
533 | */
534 | public static UIColor greenyellowColor() {
535 | return new UIColor("#adff2f");
536 | }
537 |
538 | /**
539 | * honeydew
540 | * #f0fff0
541 | * 240,255,240
542 | */
543 | public static UIColor honeydewColor() {
544 | return new UIColor("#f0fff0");
545 | }
546 |
547 | /**
548 | * hotpink
549 | * #ff69b4
550 | * 255,105,180
551 | */
552 | public static UIColor hotpinkColor() {
553 | return new UIColor("#ff69b4");
554 | }
555 |
556 | /**
557 | * indianred
558 | * #cd5c5c
559 | * 205,92,92
560 | */
561 | public static UIColor indianredColor() {
562 | return new UIColor("#cd5c5c");
563 | }
564 |
565 | /**
566 | * indigo
567 | * #4b0082
568 | * 75,0,130
569 | */
570 | public static UIColor indigoColor() {
571 | return new UIColor("#4b0082");
572 | }
573 |
574 | /**
575 | * ivory
576 | * #fffff0
577 | * 255,255,240
578 | */
579 | public static UIColor ivoryColor() {
580 | return new UIColor("#fffff0");
581 | }
582 |
583 | /**
584 | * khaki
585 | * #f0e68c
586 | * 240,230,140
587 | */
588 | public static UIColor khakiColor() {
589 | return new UIColor("#f0e68c");
590 | }
591 |
592 | /**
593 | * lavender
594 | * #e6e6fa
595 | * 230,230,250
596 | */
597 | public static UIColor lavenderColor() {
598 | return new UIColor("#e6e6fa");
599 | }
600 |
601 | /**
602 | * lavenderblush
603 | * #fff0f5
604 | * 255,240,245
605 | */
606 | public static UIColor lavenderblushColor() {
607 | return new UIColor("#fff0f5");
608 | }
609 |
610 | /**
611 | * lawngreen
612 | * #7cfc00
613 | * 124,252,0
614 | */
615 | public static UIColor lawngreenColor() {
616 | return new UIColor("#7cfc00");
617 | }
618 |
619 | /**
620 | * lemonchiffon
621 | * #fffacd
622 | * 255,250,205
623 | */
624 | public static UIColor lemonchiffonColor() {
625 | return new UIColor("#fffacd");
626 | }
627 |
628 | /**
629 | * lightblue
630 | * #add8e6
631 | * 173,216,230
632 | */
633 | public static UIColor lightblueColor() {
634 | return new UIColor("#add8e6");
635 | }
636 |
637 | /**
638 | * lightcoral
639 | * #f08080
640 | * 240,128,128
641 | */
642 | public static UIColor lightcoralColor() {
643 | return new UIColor("#f08080");
644 | }
645 |
646 | /**
647 | * lightcyan
648 | * #e0ffff
649 | * 224,255,255
650 | */
651 | public static UIColor lightcyanColor() {
652 | return new UIColor("#e0ffff");
653 | }
654 |
655 | /**
656 | * lightgoldenrodyellow
657 | * #fafad2
658 | * 250,250,210
659 | */
660 | public static UIColor lightgoldenrodyellowColor() {
661 | return new UIColor("#fafad2");
662 | }
663 |
664 | /**
665 | * lightgreen
666 | * #90ee90
667 | * 144,238,144
668 | */
669 | public static UIColor lightgreenColor() {
670 | return new UIColor("#90ee90");
671 | }
672 |
673 | /**
674 | * lightgrey
675 | * #d3d3d3
676 | * 211,211,211
677 | */
678 | public static UIColor lightgreyColor() {
679 | return new UIColor("#d3d3d3");
680 | }
681 |
682 | /**
683 | * lightpink
684 | * #ffb6c1
685 | * 255,182,193
686 | */
687 | public static UIColor lightpinkColor() {
688 | return new UIColor("#ffb6c1");
689 | }
690 |
691 | /**
692 | * lightsalmon
693 | * #ffa07a
694 | * 255,160,122
695 | */
696 | public static UIColor lightsalmonColor() {
697 | return new UIColor("#ffa07a");
698 | }
699 |
700 | /**
701 | * lightseagreen
702 | * #20b2aa
703 | * 32,178,170
704 | */
705 | public static UIColor lightseagreenColor() {
706 | return new UIColor("#20b2aa");
707 | }
708 |
709 | /**
710 | * lightskyblue
711 | * #87cefa
712 | * 135,206,250
713 | */
714 | public static UIColor lightskyblueColor() {
715 | return new UIColor("#87cefa");
716 | }
717 |
718 | /**
719 | * lightslategray
720 | * #778899
721 | * 119,136,153
722 | */
723 | public static UIColor lightslategrayColor() {
724 | return new UIColor("#778899");
725 | }
726 |
727 | /**
728 | * lightsteelblue
729 | * #b0c4de
730 | * 176,196,222
731 | */
732 | public static UIColor lightsteelblueColor() {
733 | return new UIColor("#b0c4de");
734 | }
735 |
736 | /**
737 | * lightyellow
738 | * #ffffe0
739 | * 255,255,224
740 | */
741 | public static UIColor lightyellowColor() {
742 | return new UIColor("#ffffe0");
743 | }
744 |
745 | /**
746 | * lime
747 | * #00ff00
748 | * 0,255,0
749 | */
750 | public static UIColor limeColor() {
751 | return new UIColor("#00ff00");
752 | }
753 |
754 | /**
755 | * limegreen
756 | * #32cd32
757 | * 50,205,50
758 | */
759 | public static UIColor limegreenColor() {
760 | return new UIColor("#32cd32");
761 | }
762 |
763 | /**
764 | * linen
765 | * #faf0e6
766 | * 250,240,230
767 | */
768 | public static UIColor linenColor() {
769 | return new UIColor("#faf0e6");
770 | }
771 |
772 | /**
773 | * magenta
774 | * #ff00ff
775 | * 255,0,255
776 | */
777 | public static UIColor magentaColor() {
778 | return new UIColor("#ff00ff");
779 | }
780 |
781 | /**
782 | * maroon
783 | * #800000
784 | * 128,0,0
785 | */
786 | public static UIColor maroonColor() {
787 | return new UIColor("#800000");
788 | }
789 |
790 | /**
791 | * mediumaquamarine
792 | * #66cdaa
793 | * 102,205,170
794 | */
795 | public static UIColor mediumaquamarineColor() {
796 | return new UIColor("#66cdaa");
797 | }
798 |
799 | /**
800 | * mediumblue
801 | * #0000cd
802 | * 0,0,205
803 | */
804 | public static UIColor mediumblueColor() {
805 | return new UIColor("#0000cd");
806 | }
807 |
808 | /**
809 | * mediumorchid
810 | * #ba55d3
811 | * 186,85,211
812 | */
813 | public static UIColor mediumorchidColor() {
814 | return new UIColor("#ba55d3");
815 | }
816 |
817 | /**
818 | * mediumpurple
819 | * #9370d6
820 | * 147,112,219
821 | */
822 | public static UIColor mediumpurpleColor() {
823 | return new UIColor("#9370d6");
824 | }
825 |
826 | /**
827 | * mediumseagreen
828 | * #3cb371
829 | * 60,179,113
830 | */
831 | public static UIColor mediumseagreenColor() {
832 | return new UIColor("#3cb371");
833 | }
834 |
835 | /**
836 | * mediumslateblue
837 | * #7b68ee
838 | * 123,104,238
839 | */
840 | public static UIColor mediumslateblueColor() {
841 | return new UIColor("#7b68ee");
842 | }
843 |
844 | /**
845 | * mediumspringgreen
846 | * #00fa9a
847 | * 0,250,154
848 | */
849 | public static UIColor mediumspringgreenColor() {
850 | return new UIColor("#00fa9a");
851 | }
852 |
853 | /**
854 | * mediumturquoise
855 | * #48d1cc
856 | * 72,209,204
857 | */
858 | public static UIColor mediumturquoiseColor() {
859 | return new UIColor("#48d1cc");
860 | }
861 |
862 | /**
863 | * mediumvioletred
864 | * #c71585
865 | * 199,21,133
866 | */
867 | public static UIColor mediumvioletredColor() {
868 | return new UIColor("#c71585");
869 | }
870 |
871 | /**
872 | * midnightblue
873 | * #191970
874 | * 25,25,112
875 | */
876 | public static UIColor midnightblueColor() {
877 | return new UIColor("#191970");
878 | }
879 |
880 | /**
881 | * mintcream
882 | * #f5fffa
883 | * 245,255,250
884 | */
885 | public static UIColor mintcreamColor() {
886 | return new UIColor("#f5fffa");
887 | }
888 |
889 | /**
890 | * mistyrose
891 | * #ffe4e1
892 | * 255,228,225
893 | */
894 | public static UIColor mistyroseColor() {
895 | return new UIColor("#ffe4e1");
896 | }
897 |
898 | /**
899 | * moccasin
900 | * #ffe4b5
901 | * 255,228,181
902 | */
903 | public static UIColor moccasinColor() {
904 | return new UIColor("#ffe4b5");
905 | }
906 |
907 | /**
908 | * navajowhite
909 | * #ffdead
910 | * 255,222,173
911 | */
912 | public static UIColor navajowhiteColor() {
913 | return new UIColor("#ffdead");
914 | }
915 |
916 | /**
917 | * navy
918 | * #000080
919 | * 0,0,128
920 | */
921 | public static UIColor navyColor() {
922 | return new UIColor("#000080");
923 | }
924 |
925 | /**
926 | * oldlace
927 | * #fdf5e6
928 | * 253,245,230
929 | */
930 | public static UIColor oldlaceColor() {
931 | return new UIColor("#fdf5e6");
932 | }
933 |
934 | /**
935 | * olive
936 | * #808000
937 | * 128,128,0
938 | */
939 | public static UIColor oliveColor() {
940 | return new UIColor("#808000");
941 | }
942 |
943 | /**
944 | * olivedrab
945 | * #6b8e23
946 | * 107,142,35
947 | */
948 | public static UIColor olivedrabColor() {
949 | return new UIColor("#6b8e23");
950 | }
951 |
952 | /**
953 | * orange
954 | * #ffa500
955 | * 255,165,0
956 | */
957 | public static UIColor orangeColor() {
958 | return new UIColor("#ffa500");
959 | }
960 |
961 | /**
962 | * orangered
963 | * #ff4500
964 | * 255,69,0
965 | */
966 | public static UIColor orangeredColor() {
967 | return new UIColor("#ff4500");
968 | }
969 |
970 | /**
971 | * orchid
972 | * #da70d6
973 | * 218,112,214
974 | */
975 | public static UIColor orchidColor() {
976 | return new UIColor("#da70d6");
977 | }
978 |
979 | /**
980 | * palegoldenrod
981 | * #eee8aa
982 | * 238,232,170
983 | */
984 | public static UIColor palegoldenrodColor() {
985 | return new UIColor("#eee8aa");
986 | }
987 |
988 | /**
989 | * palegreen
990 | * #98fb98
991 | * 152,251,152
992 | */
993 | public static UIColor palegreenColor() {
994 | return new UIColor("#98fb98");
995 | }
996 |
997 | /**
998 | * paleturquoise
999 | * #afeeee
1000 | * 175,238,238
1001 | */
1002 | public static UIColor paleturquoiseColor() {
1003 | return new UIColor("#afeeee");
1004 | }
1005 |
1006 | /**
1007 | * palevioletred
1008 | * #db7093
1009 | * 219,112,147
1010 | */
1011 | public static UIColor palevioletredColor() {
1012 | return new UIColor("#db7093");
1013 | }
1014 |
1015 | /**
1016 | * papayawhip
1017 | * #ffefd5
1018 | * 255,239,213
1019 | */
1020 | public static UIColor papayawhipColor() {
1021 | return new UIColor("#ffefd5");
1022 | }
1023 |
1024 | /**
1025 | * peachpuff
1026 | * #ffdab9
1027 | * 255,218,185
1028 | */
1029 | public static UIColor peachpuffColor() {
1030 | return new UIColor("#ffdab9");
1031 | }
1032 |
1033 | /**
1034 | * peru
1035 | * #cd853f
1036 | * 205,133,63
1037 | */
1038 | public static UIColor peruColor() {
1039 | return new UIColor("#cd853f");
1040 | }
1041 |
1042 | /**
1043 | * pink
1044 | * #ffc0cb
1045 | * 255,192,203
1046 | */
1047 | public static UIColor pinkColor() {
1048 | return new UIColor("#ffc0cb");
1049 | }
1050 |
1051 | /**
1052 | * plum
1053 | * #dda0dd
1054 | * 221,160,221
1055 | */
1056 | public static UIColor plumColor() {
1057 | return new UIColor("#dda0dd");
1058 | }
1059 |
1060 | /**
1061 | * powderblue
1062 | * #b0e0dd
1063 | * 176,224,230
1064 | */
1065 | public static UIColor powderblueColor() {
1066 | return new UIColor("#b0e0dd");
1067 | }
1068 |
1069 | /**
1070 | * purple
1071 | * #800080
1072 | * 128,0,128
1073 | */
1074 | public static UIColor purpleColor() {
1075 | return new UIColor("#800080");
1076 | }
1077 |
1078 | /**
1079 | * red
1080 | * #ff0000
1081 | * 255,0,0
1082 | */
1083 | public static UIColor redColor() {
1084 | return new UIColor("#ff0000");
1085 | }
1086 |
1087 | /**
1088 | * rosybrown
1089 | * #bc8f8f
1090 | * 188,0,143
1091 | */
1092 | public static UIColor rosybrownColor() {
1093 | return new UIColor("#bc8f8f");
1094 | }
1095 |
1096 | /**
1097 | * royalblue
1098 | * #41169e1
1099 | * 65,105,225
1100 | */
1101 | public static UIColor royalblueColor() {
1102 | return new UIColor("#41169e1");
1103 | }
1104 |
1105 | /**
1106 | * saddlebrown
1107 | * #8b4513
1108 | * 139,69,19
1109 | */
1110 | public static UIColor saddlebrownColor() {
1111 | return new UIColor("#8b4513");
1112 | }
1113 |
1114 | /**
1115 | * salmon
1116 | * #fa8072
1117 | * 250,128,114
1118 | */
1119 | public static UIColor salmonColor() {
1120 | return new UIColor("#fa8072");
1121 | }
1122 |
1123 | /**
1124 | * sandybrown
1125 | * #f4a460
1126 | * 244,164,96
1127 | */
1128 | public static UIColor sandybrownColor() {
1129 | return new UIColor("#f4a460");
1130 | }
1131 |
1132 | /**
1133 | * seagreen
1134 | * #2e8b57
1135 | * 46,139,87
1136 | */
1137 | public static UIColor seagreenColor() {
1138 | return new UIColor("#2e8b57");
1139 | }
1140 |
1141 | /**
1142 | * seashell
1143 | * #fff5ee
1144 | * 255,245,238
1145 | */
1146 | public static UIColor seashellColor() {
1147 | return new UIColor("#fff5ee");
1148 | }
1149 |
1150 | /**
1151 | * sienna
1152 | * #a0522d
1153 | * 160,82,45
1154 | */
1155 | public static UIColor siennaColor() {
1156 | return new UIColor("#a0522d");
1157 | }
1158 |
1159 | /**
1160 | * silver
1161 | * #c0c0c0
1162 | * 192,192,192
1163 | */
1164 | public static UIColor silverColor() {
1165 | return new UIColor("#c0c0c0");
1166 | }
1167 |
1168 | /**
1169 | * skyblue
1170 | * #87ceeb
1171 | * 135,206,235
1172 | */
1173 | public static UIColor skyblueColor() {
1174 | return new UIColor("#87ceeb");
1175 | }
1176 |
1177 | /**
1178 | * slateblue
1179 | * #6a5acd
1180 | * 106,90,205
1181 | */
1182 | public static UIColor slateblueColor() {
1183 | return new UIColor("#6a5acd");
1184 | }
1185 |
1186 | /**
1187 | * slategray
1188 | * #708090
1189 | * 112,128,144
1190 | */
1191 | public static UIColor slategrayColor() {
1192 | return new UIColor("#708090");
1193 | }
1194 |
1195 | /**
1196 | * snow
1197 | * #fffafa
1198 | * 255,250,250
1199 | */
1200 | public static UIColor snowColor() {
1201 | return new UIColor("#fffafa");
1202 | }
1203 |
1204 | /**
1205 | * springgreen
1206 | * #00ff7f
1207 | * 0,255,127
1208 | */
1209 | public static UIColor springgreenColor() {
1210 | return new UIColor("#00ff7f");
1211 | }
1212 |
1213 | /**
1214 | * steelblue
1215 | * #4682b4
1216 | * 70,130,180
1217 | */
1218 | public static UIColor steelblueColor() {
1219 | return new UIColor("#4682b4");
1220 | }
1221 |
1222 | /**
1223 | * tan
1224 | * #d2b48c
1225 | * 210,180,140
1226 | */
1227 | public static UIColor tanColor() {
1228 | return new UIColor("#d2b48c");
1229 | }
1230 |
1231 | /**
1232 | * teal
1233 | * #008080
1234 | * 0,128,128
1235 | */
1236 | public static UIColor tealColor() {
1237 | return new UIColor("#008080");
1238 | }
1239 |
1240 | /**
1241 | * thistle
1242 | * #d8bfd8
1243 | * 216,191,216
1244 | */
1245 | public static UIColor thistleColor() {
1246 | return new UIColor("#d8bfd8");
1247 | }
1248 |
1249 | /**
1250 | * tomato
1251 | * #ff6347
1252 | * 255,99,71
1253 | */
1254 | public static UIColor tomatoColor() {
1255 | return new UIColor("#ff6347");
1256 | }
1257 |
1258 | /**
1259 | * turquoise
1260 | * #40e0d0
1261 | * 64,224,208
1262 | */
1263 | public static UIColor turquoiseColor() {
1264 | return new UIColor("#40e0d0");
1265 | }
1266 |
1267 | /**
1268 | * violet
1269 | * #ee82ee
1270 | * 238,130,238
1271 | */
1272 | public static UIColor violetColor() {
1273 | return new UIColor("#ee82ee");
1274 | }
1275 |
1276 | /**
1277 | * wheat
1278 | * #f5deb3
1279 | * 245,223,179
1280 | */
1281 | public static UIColor wheatColor() {
1282 | return new UIColor("#f5deb3");
1283 | }
1284 |
1285 | /**
1286 | * white
1287 | * #ffffff
1288 | * 255,255,255
1289 | */
1290 | public static UIColor whiteColor() {
1291 | return new UIColor("#ffffff");
1292 | }
1293 |
1294 | /**
1295 | * whitesmoke
1296 | * #f5f5f5
1297 | * 245,245,245
1298 | */
1299 | public static UIColor whitesmokeColor() {
1300 | return new UIColor("#f5f5f5");
1301 | }
1302 |
1303 | /**
1304 | * yellow
1305 | * #ffff00
1306 | * 255,255,0
1307 | */
1308 | public static UIColor yellowColor() {
1309 | return new UIColor("#ffff00");
1310 | }
1311 |
1312 | /**
1313 | * yellowgreen
1314 | * #9acd32
1315 | * 154,205,50
1316 | */
1317 | public static UIColor yellowgreenColor() {
1318 | return new UIColor("#9acd32");
1319 | }
1320 |
1321 |
1322 | public Drawable getDRB() {
1323 | return drawable;
1324 | }
1325 |
1326 | }
1327 |
--------------------------------------------------------------------------------
/LemonSuperKit/lemonsuperkit/src/main/java/net/lemonsoft/lemonsuperkit/ui_kit/UIFont.java:
--------------------------------------------------------------------------------
1 | package net.lemonsoft.lemonsuperkit.ui_kit;
2 |
3 | /**
4 | * LemonKit 字体信息描述类
5 | * Created by lemonsoft on 2016/12/29.
6 | */
7 |
8 | public class UIFont {
9 | }
10 |
--------------------------------------------------------------------------------
/LemonSuperKit/lemonsuperkit/src/main/java/net/lemonsoft/lemonsuperkit/ui_kit/UIImage.java:
--------------------------------------------------------------------------------
1 | package net.lemonsoft.lemonsuperkit.ui_kit;
2 |
3 | /**
4 | * LemonKit图片资源描述对象
5 | * Created by LiuRi on 2016/12/28.
6 | */
7 |
8 | public class UIImage {
9 | }
10 |
--------------------------------------------------------------------------------
/LemonSuperKit/lemonsuperkit/src/main/java/net/lemonsoft/lemonsuperkit/ui_kit/adapter/UIScrollViewDelegateAdapter.java:
--------------------------------------------------------------------------------
1 | package net.lemonsoft.lemonsuperkit.ui_kit.adapter;
2 |
3 | import android.view.View;
4 |
5 | import net.lemonsoft.lemonsuperkit.ui_kit.delegate.UIScrollViewDelegate;
6 | import net.lemonsoft.lemonsuperkit.core.graphics.CGPoint;
7 | import net.lemonsoft.lemonsuperkit.ui_kit.ui_responder.ui_view.UIScrollView;
8 |
9 | /**
10 | * UIScrollView的代理对象适配器
11 | * Created by LiuRi on 2017/1/9.
12 | */
13 |
14 | public abstract class UIScrollViewDelegateAdapter implements UIScrollViewDelegate {
15 |
16 | @Override
17 | public void scrollViewDidScroll(UIScrollView scrollView) {
18 |
19 | }
20 |
21 | @Override
22 | public void scrollViewWillBeginDragging(UIScrollView scrollView) {
23 |
24 | }
25 |
26 | @Override
27 | public void scrollViewWillEndDragging(UIScrollView scrollView, CGPoint velocity, CGPoint targetContentOffset) {
28 |
29 | }
30 |
31 | @Override
32 | public void scrollViewDidEndDragging(UIScrollView scrollView, boolean decelerate) {
33 |
34 | }
35 |
36 | @Override
37 | public void scrollViewWillBeginDecelerating(UIScrollView scrollView) {
38 |
39 | }
40 |
41 | @Override
42 | public void scrollViewDidEndDecelerating(UIScrollView scrollView) {
43 |
44 | }
45 |
46 | @Override
47 | public void scrollViewDidEndScrollingAnimation(UIScrollView scrollView) {
48 |
49 | }
50 |
51 | @Override
52 | public void scrollViewDidEndZooming(UIScrollView scrollView, View view, float scale) {
53 |
54 | }
55 |
56 | @Override
57 | public boolean scrollViewShouldScrollToTop(UIScrollView scrollView) {
58 | return false;
59 | }
60 |
61 | @Override
62 | public void scrollViewDidScrollToTop(UIScrollView scrollView) {
63 |
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/LemonSuperKit/lemonsuperkit/src/main/java/net/lemonsoft/lemonsuperkit/ui_kit/delegate/UIApplicationDelegate.java:
--------------------------------------------------------------------------------
1 | package net.lemonsoft.lemonsuperkit.ui_kit.delegate;
2 |
3 | /**
4 | * LemonKit - UIKit 应用程序代理
5 | * 当您使用UIKit中的控件作为自己控件的时候,建议您使用此代理,否则该代理可能无法给您带来什么
6 | *
7 | * Created by LiuRi on 2017/1/10.
8 | */
9 |
10 | public class UIApplicationDelegate {
11 |
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/LemonSuperKit/lemonsuperkit/src/main/java/net/lemonsoft/lemonsuperkit/ui_kit/delegate/UIScrollViewDelegate.java:
--------------------------------------------------------------------------------
1 | package net.lemonsoft.lemonsuperkit.ui_kit.delegate;
2 |
3 | import android.view.View;
4 |
5 | import net.lemonsoft.lemonsuperkit.core.graphics.CGPoint;
6 | import net.lemonsoft.lemonsuperkit.ui_kit.ui_responder.ui_view.UIScrollView;
7 |
8 | /**
9 | * Created by LiuRi on 2017/1/5.
10 | */
11 |
12 | public interface UIScrollViewDelegate {
13 |
14 | /**
15 | * 只要ScrollView的内容偏移被改变,就会被回调
16 | */
17 | void scrollViewDidScroll(UIScrollView scrollView);
18 |
19 | // TODO
20 | /**
21 | * 只要ScrollView在被缩放的时候就会被回调(iOS>=3.2时候可用)
22 | */
23 | // void scrollViewDidZoom(UIScrollView scrollView);
24 |
25 | /**
26 | * 手指触摸ScrollView将要滑动时候被回调
27 | */
28 | void scrollViewWillBeginDragging(UIScrollView scrollView);
29 |
30 | /**
31 | * 手指即将停止触摸的时候被回调
32 | *
33 | * @param velocity 当前scrollView滚动的速度
34 | * @param targetContentOffset 照此速度移动的话的最终点
35 | */
36 | void scrollViewWillEndDragging(UIScrollView scrollView, CGPoint velocity, CGPoint targetContentOffset);
37 |
38 | /**
39 | * 当手指离开ScrollView时回调该方法
40 | *
41 | * @param decelerate 是否继续移动,如果继续移动,那么为true
42 | */
43 | void scrollViewDidEndDragging(UIScrollView scrollView, boolean decelerate);
44 |
45 | /**
46 | * 当手指离开ScrollView,滚动开始减速的时候调用
47 | */
48 | void scrollViewWillBeginDecelerating(UIScrollView scrollView);
49 |
50 | /**
51 | * 当手指离开ScrollView,滚动减速到停止后调用
52 | */
53 | void scrollViewDidEndDecelerating(UIScrollView scrollView);
54 |
55 | /**
56 | * 当ScrollView执行完动画之后被调用,通常指的是执行下面两个函数后被调用
57 | * setContentOffset()
58 | * scrollRectToVisible()
59 | */
60 | void scrollViewDidEndScrollingAnimation(UIScrollView scrollView);
61 |
62 | // TODO
63 |
64 | /**
65 | * 设置要缩放的 scrollView 上面的哪一个子视图 , 只能是子视图 , 不能是ScrollView 本身
66 | *
67 | * @return 要缩放的子视图
68 | */
69 | // View viewForZoomingInScrollView(UIScrollView scrollView);
70 |
71 | // TODO
72 | /**
73 | * 当开始缩放的时候被回调
74 | *
75 | * @param view 要缩放的子视图
76 | */
77 | // void scrollViewWillBeginZooming(UIScrollView scrollView, View view);
78 |
79 | /**
80 | * 当已经缩放的时候回调该方法,缩放在预设最小值和最大值中间的时候才可用(在回弹动画之后被调用)
81 | *
82 | * @param view 缩放的子视图
83 | * @param scale 缩放的比例
84 | */
85 | void scrollViewDidEndZooming(UIScrollView scrollView, View view, float scale);
86 |
87 | /**
88 | * 当要滚到视图顶部的时候回调此函数询问用户是否能回到顶部,该方法当设置scrollsToTop=true的时候才会回调
89 | *
90 | * @return 是否允许回到顶部的布尔值
91 | */
92 | boolean scrollViewShouldScrollToTop(UIScrollView scrollView);
93 |
94 | /**
95 | * 当已经滚动到顶部之后回调的函数(动画执行完毕)
96 | */
97 | void scrollViewDidScrollToTop(UIScrollView scrollView);
98 |
99 | }
100 |
--------------------------------------------------------------------------------
/LemonSuperKit/lemonsuperkit/src/main/java/net/lemonsoft/lemonsuperkit/ui_kit/enums/LKTextAlignment.java:
--------------------------------------------------------------------------------
1 | package net.lemonsoft.lemonsuperkit.ui_kit.enums;
2 |
3 | /**
4 | * LemonKit - 文本对齐方式
5 | * Created by LiuRi on 2017/1/4.
6 | */
7 |
8 | public enum LKTextAlignment {
9 |
10 | LEFT(0),
11 | CENTER(1),
12 | RIGHT(2),
13 | JUSTIFIED(3);
14 |
15 | private int code;
16 |
17 | LKTextAlignment(int code) {
18 | this.code = code;
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/LemonSuperKit/lemonsuperkit/src/main/java/net/lemonsoft/lemonsuperkit/ui_kit/ui_responder/ui_view/UINavigationBar.java:
--------------------------------------------------------------------------------
1 | package net.lemonsoft.lemonsuperkit.ui_kit.ui_responder.ui_view;
2 |
3 | /**
4 | * LemonKit - 导航栏控件
5 | * Created by lemonsoft on 2017/1/1.
6 | */
7 |
8 | public class UINavigationBar extends UIView {
9 | }
10 |
--------------------------------------------------------------------------------
/LemonSuperKit/lemonsuperkit/src/main/java/net/lemonsoft/lemonsuperkit/ui_kit/ui_responder/ui_view/UIScrollView.java:
--------------------------------------------------------------------------------
1 | package net.lemonsoft.lemonsuperkit.ui_kit.ui_responder.ui_view;
2 |
3 | import android.widget.RelativeLayout;
4 |
5 | import net.lemonsoft.lemonsuperkit.ui_kit.delegate.UIScrollViewDelegate;
6 | import net.lemonsoft.lemonsuperkit.core.graphics.CGPoint;
7 | import net.lemonsoft.lemonsuperkit.core.graphics.CGRect;
8 | import net.lemonsoft.lemonsuperkit.core.graphics.CGSize;
9 | import net.lemonsoft.lemonsuperkit.native_ui.extend.delegate.LKScrollViewDelegate;
10 | import net.lemonsoft.lemonsuperkit.native_ui.extend.view.LKScrollView;
11 |
12 | /**
13 | * UIScrollView 对 LKScrollView的封装
14 | * 让其和iOS的使用更相近,所有的单位都换成DP
15 | * Created by LiuRi on 2017/1/5.
16 | */
17 |
18 | public class UIScrollView extends UIView implements LKScrollViewDelegate {
19 |
20 | private UIScrollViewDelegate delegate;
21 |
22 | public UIScrollView() {
23 | super(LKScrollView.class);
24 | }
25 |
26 | public UIScrollView(CGRect frame) {
27 | super(LKScrollView.class, frame);
28 | }
29 |
30 | /**
31 | * 动画滚动到指定的水平位置
32 | *
33 | * @param x 水平位置x坐标
34 | */
35 | public void scrollToX(float x, boolean animated) {
36 | _gRV().scrollToX(_ST.DP(x), animated);
37 | }
38 |
39 | /**
40 | * 动画滚动到指定的纵坐标
41 | *
42 | * @param y 垂直位置y坐标
43 | */
44 | public void scrollToY(float y, boolean animated) {
45 | _gRV().scrollToY(_ST.DP(y), animated);
46 | }
47 |
48 | /**
49 | * 滚动到指定的位置
50 | *
51 | * @param point 位置信息
52 | */
53 | public void scrollTo(CGPoint point, boolean animated) {
54 | point.x = _ST.DP(point.x);
55 | point.y = _ST.DP(point.y);
56 | _gRV().scrollTo(point, animated);
57 | }
58 |
59 | public CGPoint getContentOffset() {
60 | return new CGPoint(_ST.pxToDp(_gRV().getContentOffset().x),
61 | _ST.pxToDp(_gRV().getContentOffset().y));
62 | }
63 |
64 | /**
65 | * 设置内容偏移位置信息
66 | *
67 | * @param point 偏移到的点的位置
68 | * @param animated 是否使用动画
69 | */
70 | public void setContentOffset(CGPoint point, boolean animated) {
71 | scrollTo(point, animated);
72 | }
73 |
74 | /**
75 | * 无动画直接定位到指定偏移坐标
76 | *
77 | * @param point 要偏移到的点
78 | */
79 | public void setContentOffset(CGPoint point) {
80 | setContentOffset(point, false);
81 | }
82 |
83 | public CGSize getContentSize() {
84 | return CGSize.make(_ST.pxToDp(_gRV().getContentSize().width), _ST.pxToDp(_gRV().getContentSize().height));
85 | }
86 |
87 | public void setContentSize(CGSize contentSize) {
88 | contentSize.width = _ST.DP(contentSize.width);
89 | contentSize.height = _ST.DP(contentSize.height);
90 | _gRV().setContentSize(contentSize);
91 | }
92 |
93 | public boolean isBounces() {
94 | return _gRV().isBounces();
95 | }
96 |
97 | public void setBounces(boolean bounces) {
98 | _gRV().setBounces(bounces);
99 | }
100 |
101 | public UIScrollViewDelegate getDelegate() {
102 | return delegate;
103 | }
104 |
105 | public void setDelegate(UIScrollViewDelegate delegate) {
106 | this.delegate = delegate;
107 | _gRV().setDelegate(this);
108 | }
109 |
110 | public void addSubView(UIView view) {
111 | _gRV().addView(view);
112 | view.setLayoutParams(new RelativeLayout.LayoutParams(_ST.DP(view.frame.size.width), _ST.DP(view.frame.size.height)));
113 | }
114 |
115 | // 中转调用LKScrollViewDelegate
116 |
117 |
118 | @Override
119 | public void scrollViewDidScroll(LKScrollView scrollView) {
120 | if (delegate != null)
121 | delegate.scrollViewDidScroll(this);
122 | }
123 |
124 | @Override
125 | public void scrollViewWillBeginDragging(LKScrollView scrollView) {
126 | if (delegate != null)
127 | delegate.scrollViewWillBeginDecelerating(this);
128 | }
129 |
130 | @Override
131 | public void scrollViewWillEndDragging(LKScrollView scrollView, CGPoint velocity, CGPoint targetContentOffset) {
132 | if (delegate != null)
133 | delegate.scrollViewWillEndDragging(this,
134 | new CGPoint(_ST.pxToDp(velocity.x), _ST.pxToDp(velocity.y)),
135 | new CGPoint(_ST.pxToDp(targetContentOffset.x), _ST.pxToDp(targetContentOffset.y)));
136 | }
137 |
138 | @Override
139 | public void scrollViewDidEndDragging(LKScrollView scrollView, boolean decelerate) {
140 | if (delegate != null)
141 | delegate.scrollViewDidEndDragging(this, decelerate);
142 | }
143 |
144 | @Override
145 | public void scrollViewWillBeginDecelerating(LKScrollView scrollView) {
146 | if (delegate != null)
147 | delegate.scrollViewWillBeginDecelerating(this);
148 | }
149 |
150 | @Override
151 | public void scrollViewDidEndDecelerating(LKScrollView scrollView) {
152 | if (delegate != null)
153 | delegate.scrollViewDidEndDecelerating(this);
154 | }
155 |
156 | @Override
157 | public void scrollViewDidEndScrollingAnimation(LKScrollView scrollView) {
158 | if (delegate != null)
159 | delegate.scrollViewDidEndScrollingAnimation(this);
160 | }
161 | }
162 |
--------------------------------------------------------------------------------
/LemonSuperKit/lemonsuperkit/src/main/java/net/lemonsoft/lemonsuperkit/ui_kit/ui_responder/ui_view/UIView.java:
--------------------------------------------------------------------------------
1 | package net.lemonsoft.lemonsuperkit.ui_kit.ui_responder.ui_view;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.view.View;
6 | import android.widget.RelativeLayout;
7 |
8 | import net.lemonsoft.lemonsuperkit.core_animation.CALayer;
9 | import net.lemonsoft.lemonsuperkit.core.base.LemonKit;
10 | import net.lemonsoft.lemonsuperkit.core.graphics.CGRect;
11 | import net.lemonsoft.lemonsuperkit.core.graphics.CGSize;
12 | import net.lemonsoft.lemonsuperkit.native_ui.tools.LKSizeTool;
13 | import net.lemonsoft.lemonsuperkit.native_ui.tools.LKViewAppearanceTool;
14 | import net.lemonsoft.lemonsuperkit.ui_kit.UIColor;
15 |
16 | import java.lang.reflect.Constructor;
17 |
18 | /**
19 | * 视图控件,LemonKit中所有视图控件的父类
20 | * Created by LiuRi on 2016/12/28.
21 | */
22 |
23 | public class UIView extends RelativeLayout {
24 |
25 | /**
26 | * LemonKit核心对象
27 | */
28 | protected LemonKit _LK = LemonKit.instance();
29 | /**
30 | * 尺寸控件类
31 | */
32 | protected LKSizeTool _ST = LKSizeTool.getDefaultSizeTool();
33 |
34 | protected LKViewAppearanceTool _VAT = LKViewAppearanceTool.getDefaultViewAppearanceTool();
35 | /**
36 | * 控件的矩形信息
37 | */
38 | protected CGRect frame = new CGRect(0f, 0f, 0f, 0f);
39 | /**
40 | * 超过应显示区域的部分截断
41 | */
42 | private boolean clipsToBounds = false;
43 | /**
44 | * 实际的内容控件
45 | */
46 | protected View _rView;
47 | /**
48 | * 高级视图操作属性
49 | */
50 | public CALayer layer = new CALayer(this);
51 | /**
52 | * 父层控件
53 | */
54 | private UIView _superView;
55 |
56 | public UIView() {
57 | super(LemonKit.instance().getAppContext());
58 | commonInit();// 调用公共初始化方法
59 | }
60 |
61 | /**
62 | * 通过初始化frame来构造对象
63 | *
64 | * @param frame 控件外观矩形信息描述对象
65 | */
66 | public UIView(CGRect frame) {
67 | this();
68 | this.frame = frame;
69 | }
70 |
71 | /**
72 | * 子类通过此构造方法把基础的AndroidView控件封装成LemonKit的UIView子控件
73 | *
74 | * @param viewClass androidView控件
75 | */
76 | protected UIView(Class viewClass) {
77 | this();
78 | try {
79 | Constructor constructor = viewClass.getConstructor(Context.class);
80 | this._rView = constructor.newInstance(getContext());
81 | this.addView(_rView);
82 | } catch (Exception e) {
83 | e.printStackTrace();
84 | }
85 | }
86 |
87 | /**
88 | * 子类通过此构造方法把基础的AndroidView控件封装成LemonKit的UIView子控件,并直接设置frame
89 | *
90 | * @param viewClass androidView控件
91 | * @param frame 控件的矩形信息
92 | */
93 | protected UIView(Class viewClass, CGRect frame) {
94 | this(viewClass);
95 | setFrame(frame);
96 | }
97 |
98 | /**
99 | * 获取实际显示的控件
100 | *
101 | * @return 实际显示的控件View对象
102 | */
103 | public View get_rView() {
104 | return _rView;
105 | }
106 |
107 | /**
108 | * 初始化,所有的构造方法都要调用此函数
109 | */
110 | private void commonInit() {
111 | setBackgroundColor(new UIColor(0, 1, 1, 1));
112 | }
113 |
114 | /**
115 | * 获取真实显示内容的控件,getRealView
116 | *
117 | * @return 真实显示内容的视图对象
118 | */
119 | protected T _gRV() {
120 | return (T) _rView;
121 | }
122 |
123 | /**
124 | * 获取当前视图的矩形信息
125 | *
126 | * @return 矩形信息
127 | */
128 | public CGRect getFrame() {
129 | return frame;
130 | }
131 |
132 | /**
133 | * 设置控件的X坐标,单位DP
134 | *
135 | * @param x 横坐标X,单位DP
136 | */
137 | @Override
138 | public void setX(float x) {
139 | super.setX(_ST.DP(x));
140 | this.frame.origin.x = x;
141 | refresh();
142 | }
143 |
144 | /**
145 | * 设置控件的Y坐标,单位DP
146 | *
147 | * @param y 纵坐标Y,单位DP
148 | */
149 | @Override
150 | public void setY(float y) {
151 | super.setY(_ST.DP(y));
152 | this.frame.origin.y = y;
153 | refresh();
154 | }
155 |
156 | /**
157 | * 设置控件的宽,单位DP
158 | *
159 | * @param width 控件的宽度,单位DP
160 | */
161 | public void setWidth(float width) {
162 | this.frame.size.width = width;
163 | _VAT.setWidth(this, width);
164 | refresh();
165 | }
166 |
167 | /**
168 | * 设置控件的高,单位DP
169 | *
170 | * @param height 控件的高度,单位DP
171 | */
172 | public void setHeight(float height) {
173 | this.frame.size.height = height;
174 | _VAT.setHeight(this, height);
175 | refresh();
176 | }
177 |
178 | /**
179 | * 设置控件的尺寸
180 | *
181 | * @param width 要设置的控件的宽
182 | * @param height 要设置的控件的高
183 | */
184 | public void setSize(float width, float height) {
185 | this.frame.size.width = width;
186 | _VAT.setWidth(this, width);
187 | this.frame.size.height = height;
188 | _VAT.setHeight(this, height);
189 | refresh();
190 | }
191 |
192 | @Override
193 | protected void onDraw(Canvas canvas) {
194 | super.onDraw(canvas);
195 | layer.onDraw(canvas);
196 | }
197 |
198 | /**
199 | * 设置控件的尺寸
200 | *
201 | * @param size 要设置的控件的尺寸描述对象
202 | */
203 | public void setSize(CGSize size) {
204 | setSize(size.width, size.height);
205 | }
206 |
207 | /**
208 | * 设置控件的矩形信息
209 | *
210 | * @param frame 控件的举行信息
211 | */
212 | public void setFrame(CGRect frame) {
213 | this.frame = frame;
214 | super.setX(_ST.DP(frame.origin.x));
215 | super.setY(_ST.DP(frame.origin.y));
216 |
217 | _VAT.setWidth(this, frame.size.width);
218 | _VAT.setHeight(this, frame.size.height);
219 | refresh();
220 | }
221 |
222 | /**
223 | * 设置控件的尺寸,单位DP
224 | *
225 | * @param width 控件的宽度,单位DP
226 | * @param height 控件的高度,单位DP
227 | */
228 | public void setSize(int width, int height) {
229 | _VAT.setSize(this, width, height);
230 | }
231 |
232 | /**
233 | * 设置背景颜色
234 | *
235 | * @param color LemonKit背景颜色对象
236 | */
237 | public void setBackgroundColor(UIColor color) {
238 | this.layer.setBackgroundColor(color);
239 | }
240 |
241 | /**
242 | * 获取控件的背景颜色对象
243 | *
244 | * @return UIColor颜色描述对象
245 | */
246 | public UIColor getBackgroundColor() {
247 | return this.layer.getBackgroundColor();
248 | }
249 |
250 | /**
251 | * 刷新布局
252 | */
253 | protected void refresh() {
254 | if (_rView != null) {
255 | _VAT.setOrigin(_rView, 0, 0);// 始终在左上角
256 | _VAT.setSize(_rView, this.frame.size);// 设置实际控件和容器控件的尺寸一致
257 | }
258 | }
259 |
260 | public void addSubView(UIView view) {
261 | this.addView(view);
262 | }
263 |
264 | // 无特殊要求的getter 、setter方法开始.....
265 | public UIView get_superView() {
266 | return _superView;
267 | }
268 |
269 | public void set_superView(UIView _superView) {
270 | this._superView = _superView;
271 | }
272 |
273 | public boolean isClipsToBounds() {
274 | return clipsToBounds;
275 | }
276 |
277 | public void setClipsToBounds(boolean clipsToBounds) {
278 | this.clipsToBounds = clipsToBounds;
279 | this.layer.setMasksToBounds(clipsToBounds);
280 | }
281 |
282 | // ......无特殊要求的getter 、setter方法结束
283 | }
284 |
--------------------------------------------------------------------------------
/LemonSuperKit/lemonsuperkit/src/main/java/net/lemonsoft/lemonsuperkit/ui_kit/ui_responder/ui_view/ui_control/UIButton.java:
--------------------------------------------------------------------------------
1 | package net.lemonsoft.lemonsuperkit.ui_kit.ui_responder.ui_view.ui_control;
2 |
3 | import android.widget.Button;
4 |
5 | import net.lemonsoft.lemonsuperkit.core.graphics.CGRect;
6 |
7 | /**
8 | * 按钮控件
9 | * Created by LiuRi on 2016/12/28.
10 | */
11 |
12 | public class UIButton extends UIControl