I have made XML markup for part of my program.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="20dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
xmlns:tools="http://schemas.android.com/tools"
android:background="@drawable/checked_border">
<ImageView
android:id="@+id/asset_icon"
android:layout_width="60dp"
android:layout_height="60dp"
tools:srcCompat="@drawable/ic_dollar" />
<LinearLayout
android:id="@+id/asset_name_and_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="@id/asset_icon"
android:orientation="vertical">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Name" />
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="count" />
</LinearLayout>
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:text="sum" />
</RelativeLayout>
After that, I tried to add it using inflater
LayoutInflater ltInflater = getLayoutInflater();
RelativeLayout assetlayout = (RelativeLayout)
ltInflater.inflate(R.layout.asset_layout, null, false);
LinearLayout assets = findViewById(R.id.assetslayout);
assets.addView(assetlayout);
So that what I expected to see. Also, you can see a top margin.
But when I run my program I don't see an image view and there are no top margins at all.