Suppose we are developing a composite component based on LinearLayout. So, we create the class as follows:
public class SomeView extends LinearLayout { public SomeView(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(LinearLayout.VERTICAL); View.inflate(context, R.layout.somelayout, this); } }
If we use LinearLayout as the root of somelayout.xml , we will have an extra level of presentation, so we use the merge tag:
<?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>
But on the Preview tab in the IDE, the merge always acts like a FrameLayout, and we will see something like this: 
(This is Android Studio, Intellij IDEA is the same about Eclipse that I don't know)
Previewing speeds up the development of layouts a lot, it’s sad to lose so much help even for some layouts. Maybe there is a way to indicate how Preview should interpret the merge tag in a specific layout?
android android-layout intellij-idea android-studio android-tools-namespace
darja Jun 25 '13 at 11:50 2013-06-25 11:50
source share