You have to add two xml layout name bottom and top, then you can use it in any layout you want,just add this code
<include layout="@layout/top" />
<include layout="@layout/bottom" />
this solution is useful for toolbar layout.
in bottom and top layout, write your code that you want reuse it.
Example:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/top" />
<ImageView
android:id="@+id/your_dynamic_part"
android:layout_width="wrap_content"
android:layout_height="300dp" />
<include layout="@layout/bottom" />
</LinearLayout>