in Android, I want to do something similar (but with two alternating colors, black and white:
color change with ripple effect like this

What I tried to do:
1) set default backgroundTint and ripple color via XML
app:backgroundTint="@android:color/black"
app:rippleColor="@android:color/white"
2) in the onclick method, changed backgroundTint to white and ripple color to black
set the line for the initial color, i.e. high_color = "black". then
fab.setOnClickListener(new View.OnClickListener() {
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public void onClick(View v) {
if(high_color.equals("black")){
fab.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(getApplicationContext(), R.color.white)));
fab.setImageTintList(ColorStateList.valueOf(ContextCompat.getColor(getApplicationContext(), R.color.black)));
fab.setRippleColor(ContextCompat.getColor(getApplicationContext(), R.color.black));
high_color = "white";
}else {
fab.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(getApplicationContext(), R.color.black)));
fab.setImageTintList(ColorStateList.valueOf(ContextCompat.getColor(getApplicationContext(), R.color.white)));
fab.setRippleColor(ContextCompat.getColor(getApplicationContext(), R.color.whites));
high_color = "black";
}
}
});
now i get something like this:
what i get is

Anyway, to make it look like the first? for example, by slowing down the speed of the ripple animation or something like that?
source
share