I have a scrollview with 6 buttons that change the background according to a previously chosen numberpicker, When I change the number of the number picker and it removes the existing buttons and creates again with the correct background for that chosen number, all right so the problem is that when it does this rebuild the scrollview flashes, and it looks pretty ugly, it looks like a glitch, how could it animate this re-creation of buttons?
My method:
private void criardias(int diapreparacao) {
layoutbtns.removeAllViewsInLayout();
for (int i = 1; i <= 6 ; i++) {
FancyButton diabtn = new FancyButton(getContext());
diabtn.setText("Dia " + i);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(135, 135);
layoutParams.setMargins(8, 0, 8, 0);
diabtn.setLayoutParams(layoutParams);
diabtn.setRadius(64);
diabtn.setTextSize(15);
diabtn.setRadius(64);
diabtn.setBackground(getResources().getDrawable(R.drawable.selectorbtndia));
if (i == diapreparacao) {
diabtn.setTextColor(getResources().getColor(R.color.vermelhoperfil));
diabtn.setBackground(getResources().getDrawable(R.drawable.btndiaatual));
} else {
if (i < diapreparacao) {
diabtn.setBackground(getResources().getDrawable(R.drawable.btndiadisponivel));
} else {
diabtn.setEnabled(false);
diabtn.setBackground(getResources().getDrawable(R.drawable.btndiadisabilitado));
}
}
layoutbtns.addView(diabtn);
}
}