Tengo dos botones: "btn1, btn2", el btn2 cambiará aleatoriamente cuando cambie el fondo de btn1 alfa
Tengo dos botones:btn1
, btn2
. Se utilizan con una misma imagen de fondo:pic1.png
. Cuando cambié el fondo del primer botón:btn1
enOnTouch
evento, el código es el siguiente
onTouch_Action(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
TextView tv = (TextView) v;
int color = tv.getCurrentTextColor();
int r = (color) & 0xFF;
int g = (color >> 8) & 0xFF;
int b = (color >> 16) & 0xFF;
int a = (color >> 24) & 0xFF;
tv.setTextColor(Color.argb(50, r, g, b)); //The other uses the same background image buttons may also change
} else if (event.getAction() == MotionEvent.ACTION_UP) {
int color = tv.getCurrentTextColor();
int r = (color) & 0xFF;
int g = (color >> 8) & 0xFF;
int b = (color >> 16) & 0xFF;
int a = (color >> 24) & 0xFF;
tv.setTextColor(Color.argb(255, r, g, b)); //The other uses the same background image buttons may also change
}
}
El segundo botón:btn2
, el fondo también se puede cambiar, y los cambios son aleatorios. ¿Cómo evitar que el segundo botón cambie?