|
4 | 4 | import android.content.res.ColorStateList; |
5 | 5 | import android.graphics.Color; |
6 | 6 | import android.graphics.drawable.Drawable; |
| 7 | +import android.graphics.drawable.GradientDrawable; |
7 | 8 | import android.os.Build; |
8 | 9 | import android.os.Bundle; |
9 | 10 | import android.support.annotation.Nullable; |
@@ -38,16 +39,24 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { |
38 | 39 | ColorStateList colors = new DrawableCreator.Builder().setPressedTextColor(Color.RED).setUnPressedTextColor(Color.BLUE).buildTextColor(); |
39 | 40 | tvTest1.setTextColor(colors); |
40 | 41 |
|
41 | | - Button btnTest2 = findViewById(R.id.btnTest2); |
42 | | - Drawable drawable2 = new DrawableCreator.Builder().setCornersRadius(dip2px(20)) |
43 | | - .setGradientAngle(0).setGradientColor(Color.parseColor("#63B8FF"), Color.parseColor("#4F94CD")).build(); |
| 42 | + TextView btnTest2 = findViewById(R.id.btnTest2); |
| 43 | + btnTest2.setEnabled(false); |
| 44 | + GradientDrawable drawable2; |
| 45 | + drawable2 = new GradientDrawable(); |
| 46 | + int[][] state = new int[2][]; |
| 47 | + int[] color = new int[2]; |
| 48 | + state[0] = new int[]{android.R.attr.state_pressed}; |
| 49 | + state[1] = new int[]{-android.R.attr.state_pressed}; |
| 50 | + color[0] = R.color.colorAccent; |
| 51 | + color[1] = R.color.colorPrimaryDark; |
| 52 | + ColorStateList colorStateList = new ColorStateList(state, color); |
| 53 | +// drawable2.setColor(colorStateList); |
44 | 54 | if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN){ |
45 | 55 | btnTest2.setBackground(drawable2); |
46 | 56 | }else { |
47 | 57 | btnTest2.setBackgroundDrawable(drawable2); |
48 | 58 | } |
49 | 59 |
|
50 | | - |
51 | 60 | Button btnTest3 = findViewById(R.id.btnTest3); |
52 | 61 | Drawable drawable3 = new DrawableCreator.Builder().setCornersRadius(dip2px(20)) |
53 | 62 | .setRipple(true, Color.parseColor("#71C671")) |
|
0 commit comments