btn1
、の 2 つのボタンがありますbtn2
。これらは同じ背景画像で使用されます: pic1.png
. 最初のボタンの背景を変更したとき:イベントbtn1
でOnTouch
は、コードは次のとおりです。
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
}
}
2 番目のボタン: btn2
、背景も変更される場合があり、変更はランダムです。2番目のボタンの変更を回避するには?