mercredi 7 octobre 2015

android - XML-created and Code-created checkboxes are different

I'm creating checkboxes in 2 diffent ways:

1) XML

<CheckBox
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="-10dp"
    android:id="@+id/checkBox1" />

2) Java-code

 CheckBox myCheckBox = new CheckBox(this);
 myLayout.addView(myCheckBox);

And the look differently The one from code:

code checked code unchecked

And from XML:

xml checked xml unchecked

Why is that? And how can I make them equal?




Aucun commentaire:

Enregistrer un commentaire