33import android .graphics .Color ;
44import android .os .Bundle ;
55import android .support .v7 .app .AppCompatActivity ;
6- import android .text .SpannableString ;
7- import android .text .style .ForegroundColorSpan ;
8- import android .util .Log ;
96import android .view .View ;
107import android .widget .TextView ;
118
12- import com .study .xuan .easywidget .EasyTextView ;
139import com .study .xuan .shapebuilder .annotation .Shape ;
1410import com .study .xuan .shapebuilder .shape .LayerBuilder ;
1511import com .study .xuan .shapebuilder .shape .ShapeBuilder ;
1612import com .study .xuan .shapebuilder .shape .ShapeListBuilder ;
1713
14+ import static android .graphics .drawable .GradientDrawable .OVAL ;
1815import static android .graphics .drawable .GradientDrawable .RECTANGLE ;
16+ import static android .graphics .drawable .GradientDrawable .RING ;
1917
2018public class MainActivity extends AppCompatActivity {
2119 @ Shape (RECTANGLE )
@@ -24,40 +22,38 @@ public class MainActivity extends AppCompatActivity{
2422 protected void onCreate (Bundle savedInstanceState ) {
2523 super .onCreate (savedInstanceState );
2624 setContentView (R .layout .activity_main );
27- ShapeBuilder builder1 = ShapeBuilder .create ()
25+
26+ ShapeBuilder .create ()
2827 .Type (RECTANGLE )
29- .Soild (Color .RED );
28+ .Radius (35 )
29+ .Stroke (15 ,Color .BLACK )
30+ .Solid (Color .RED )
31+ .build (findViewById (R .id .tv1 ));
32+
33+ ShapeBuilder builder1 = ShapeBuilder .create ()
34+ .Type (OVAL )
35+ .Solid (Color .RED );
3036 ShapeBuilder builder2 = ShapeBuilder .create ()
3137 .Type (RECTANGLE )
32- .Soild (Color .RED );
38+ .Solid (Color .RED );
3339 ShapeListBuilder .create (builder1 .build ())
34- .addShape (builder2 .Soild (Color .BLUE ).build (), android .R .attr .state_selected )
35- .build (findViewById (R .id .tv1 ));
36- findViewById (R .id .tv1 ).setOnClickListener (new View .OnClickListener () {
40+ .addShape (builder2 .Solid (Color .BLUE ).build (), android .R .attr .state_selected )
41+ .build (findViewById (R .id .tv2 ));
42+ findViewById (R .id .tv2 ).setOnClickListener (new View .OnClickListener () {
3743 @ Override
3844 public void onClick (View view ) {
39- findViewById (R .id .tv1 ).setSelected (!findViewById (R .id .tv1 ).isSelected ());
40- }
41- });
42-
43- LayerBuilder .create (builder1 .build (), builder2 .build ()).Bottom (1 , 15 ).build (findViewById (R
44- .id .tv3 ));
45- /*TextView ic = (TextView) findViewById(R.id.easyText);
46- Log.i("TAG", "---" + ic.getText().toString() + "----");
47- ic.append("300");
48-
49- ForegroundColorSpan foregroundColorSpan = new ForegroundColorSpan(Color.parseColor
50- ("#11FFFC"));
51- SpannableString spannableString = new SpannableString("+++"+ic.getText());
52- spannableString.setSpan(foregroundColorSpan, 0, 1, 1);
53- ic.setText(spannableString);*/
54- final EasyTextView ic = (EasyTextView ) findViewById (R .id .easyText );
55- ic .setOnClickListener (new View .OnClickListener () {
56- @ Override
57- public void onClick (View v ) {
58- ic .setIconColor (Color .parseColor ("#2E7D19" ));
45+ findViewById (R .id .tv2 ).setSelected (!findViewById (R .id .tv2 ).isSelected ());
5946 }
6047 });
6148
49+ LayerBuilder .create (
50+ ShapeBuilder .create ()
51+ .Type (RECTANGLE )
52+ .Solid (Color .BLACK ).build (),
53+ ShapeBuilder .create ()
54+ .Type (RECTANGLE )
55+ .Solid (Color .RED ).build ())
56+ .Bottom (1 , 15 )
57+ .build (findViewById (R .id .tv3 ));
6258 }
6359}
0 commit comments