title: Is there a way to programmatically create copies of a layout in android?
body: <p>The main goal is to use a pre-made layout to create separate modules that can be edited, and then programmatically add them to the root layout. To clarify, <a href="https://i.stack.imgur.com/JA28s.png" rel="nofollow noreferrer">several modules stuck together would look like this.</a> I would like to dynamically create each clickable block that consists of a name, date, and letter. The .axml code for each block is as follows: </p>
  
  <pre><code>        &lt;RelativeLayout
              android:minWidth="25px"
              android:minHeight="25px"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:id="@+id/borderLayout"
              android:background="@drawable/line"
              android:paddingBottom="1dp"
              android:paddingTop="1dp"&gt;
              &lt;RelativeLayout
                  android:id="@+id/relativeLayout1"
                  android:padding="10dp"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:clickable="true"
                  android:background="#ff2f2f2f"&gt;
                  &lt;TextView
                      android:text="C"
                      android:textAppearance="?android:attr/textAppearanceLarge"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:id="@+id/textView1"
                      android:layout_alignParentLeft="true"
                      android:textSize="30dp" /&gt;
                  &lt;TextView
                      android:text="Washington"
                      android:textAppearance="?android:attr/textAppearanceMedium"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:layout_toRightOf="@id/textView1"
                      android:id="@+id/textView2"
                      android:layout_alignParentRight="true"
                      android:gravity="right" /&gt;
                  &lt;TextView
                      android:text="6-8-17"
                      android:textAppearance="?android:attr/textAppearanceSmall"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:layout_below="@id/textView2"
                      android:id="@+id/textView3"
                      android:gravity="right"
                      android:layout_alignParentRight="true" /&gt;
              &lt;/RelativeLayout&gt;
          &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>The main problem I am having is formatting the views programmatically in the same way that I formatted them in the .axml file. </p>