Using the following code within a RecyclerView.Adapter:
onBindViewHolder(VH holder, int position){
holder.itemView.setAlpha(0.5f);
}
Alpha will not be shown the first time the item is shown. However, if you leave the screen and come back, Alpha is then accurately shown. The value is being set, but not displayed until it's shown again. Any ideas on how to get setAlpha() to take effect on first viewing.
After further investigation, this happens only when using an animator (such as the android.support.v7.widget.DefaultItemAnimator ) which will clear whatever alpha is set for the view. You can use
RecyclerView.setItemAnimator(null);
and alpha will remain set
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With