Android Add a Fragment to an Activity using XML

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="iterator.ir.a033.MainActivity"
    android:orientation="vertical">

    <fragment
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:name="iterator.ir.a033.FirstFragment"
        android:id="@+id/fragment1"
        tools:layout="@layout/fragment_first" />

    <View
        android:layout_width="match_parent"
        android:layout_height="20dp" />

    <fragment
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:name="iterator.ir.a033.SecondFragment"
        android:id="@+id/fragment2"
        tools:layout="@layout/fragment_second" />

</LinearLayout>

References
https://github.com/mhdr/AndroidSamples/tree/master/033