0
I have a scrollview with 6 buttons that change the background according to a previously chosen numberpicker, When I change the number of the Picker number and it removes the existing buttons and creates again with the correct background for that chosen number, all right so far, the problem is that when he does this reconstruction the scrollview flashes, and it looks really ugly, looks like a Glitch, would have to animate this re-creation of buttons?
My way:
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);
}
}