dans Android, je veux faire quelque chose comme ça (mais avec 2 couleurs alternées en noir et blanc:Changer la couleur FAB avec effet d'entraînement
changeant de couleur avec effet d'entraînement comme celui-ci
Qu'est-ce que J'ai essayé de le faire est:
1) paramètre par défaut défini backgroundTint & couleur ondulation via XML
app:backgroundTint="@android:color/black"
app:rippleColor="@android:color/white"
2) dans la méthode onclick, a changé de couleur blanche backgroundTint et l'ondulation de noir
définir une chaîne de couleur initiale à-dire high_color = "black"
. puis,
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";
}
}
});
maintenant je reçois quelque chose comme ceci:
ce que je reçois est ce
est là de toute façon de faire celui-ci ressemble au premier? comme ralentir la vitesse d'animation ondulation ou quelque chose comme ça?
oeil à cette bibliothèque: https: // GitHub.com/ozodrukh/RippleDrawable – rafsanahmad007
Cela ne ressemble pas à un effet d'entraînement pour moi. Avez-vous essayé Circular Reveal pour cela? vérifiez ceci: https://guides.codepath.com/android/Circular-Reveal-Animation. Et ceci: https://developer.android.com/training/material/animations.html –
Ah, si vous voulez un exemple ... vérifiez mon repo, il fait exactement ce que vous voulez, mais sur un CustomView, dans ce file: https://github.com/leandroBorgesFerreira/LoadingButtonAndroid/blob/master/loading-button-android/src/main/java/br/com/simplepass/loading_button_lib/AnimatedDrawables/CircularRevealAnimatedDrawable.java –