如何给merge之下的framelayout建立一个自定义view,安卓代码实现

问题遇到的现象和发生背景

我只需要把merge下面的framelayout建立一个自定义view
但不是如下所示,这样会报错

private View mInflate;

 mInflate = LayoutInflater
                .from(context)
                .inflate(R.id.layout1, this);

问题相关代码,请勿粘贴截图
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:clipChildren="false"
    tools:parentTag="android.widget.LinearLayout">

    <FrameLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/layout1"
        android:layout_marginLeft="-65dp"
        android:clipChildren="false">
</FrameLayout>
</merge>

运行结果及报错内容
我的解答思路和尝试过的方法
我想要达到的结果

img


这里参数不是控件id,是这个资源文件的地址,R.layout.你的xml资源文件名

FrameLayout下自定义View?是FrameLayout加一个自定义View当子View吗,那直接通过FrameLayout.addView加入即可