Adding constraints to a view in a ConstraintLayout ignore left and right margins
I want to add some views to a ConstraintLayout in java. This is the layout xml: <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/constraint_layout" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> </android.support.constraint.ConstraintLayout> and this is the code of the activity: public class MainActivity extends AppCompatActivity { private ConstraintLayout