假设我们正在开发基于LinearLayout的复合组件。因此,我们创建这样的类:
public class SomeView extends LinearLayout {
    public SomeView(Context context, AttributeSet attrs) {
        super(context, attrs);
        setOrientation(LinearLayout.VERTICAL);
        View.inflate(context, R.layout.somelayout, this);
    }
}如果将LinearLayout用作的根,则将somelayout.xml具有额外的视图级别,因此我们使用merge标签:
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Some text"
        android:textSize="20sp"/>
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Some other text"/>
</merge>但是在IDE的“预览”选项卡中,合并始终充当FrameLayout,我们将看到类似的内容:

(这是Android Studio,Intellij IDEA也是一样,关于Eclipse我不知道)
预览大大加快了版面的开发速度,令人遗憾的是,即使对于某些版面,失去这么大的帮助。也许有一种方法可以指定,预览应如何解释merge特定布局中的标签?