Okay, so that's the problem: When I try to create dynamically some checkboxes, they don't get the material theme even if I'm inflating them from an xml file.
EDIT:
java:
setContentView(R.layout.activity_volumi);
FloatingActionButton add = (FloatingActionButton) findViewById(R.id.add);
final LinearLayout ll = (LinearLayout) findViewById(R.id.home);
add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "Aggiunta", Toast.LENGTH_SHORT).show();
LinearLayout ll4;;// = new LinearLayout(getApplicationContext());
ll4 = (LinearLayout) View.inflate(getApplicationContext(), R.layout.volume, null);
ll.addView(ll4);
//CheckBox cb;// = new CheckBox(getApplicationContext());
//cb = (CheckBox) View.inflate(getApplicationContext(), R.layout.dynamic_check, null);
//cb.setText("I'm dynamic!");
//cb.setBackgroundColor(getResources().getColor(R.color.myPrimaryColor));
//cb.setId();
Toast.makeText(getApplicationContext(), "Aggiunto", Toast.LENGTH_SHORT).show();
}
});
EDIT:
Thanks to Riccardo Ciovati now it works :D
If it's only about checkboxes, you can instantiate a tint-aware
CheckBox
with the AppCompatCheckBox class.There are other similar classes, like