LinearLayout을 기반으로 복합 컴포넌트를 개발하고 있다고 가정 해 보겠습니다. 그래서, 우리는 다음과 같이 클래스를 만들 : 우리가 somelayout.xml
의 루트로 LinearLayout
를 사용합니다 경우Intellij IDEA/Android Studio에서 병합 루트 태그가있는 미리보기 레이아웃
public class SomeView extends LinearLayout {
public SomeView(Context context, AttributeSet attrs) {
super(context, attrs);
setOrientation(LinearLayout.VERTICAL);
View.inflate(context, R.layout.somelayout, this);
}
}
, 우리는 여분의보기 수준이있을 것이다, 그래서 우리는 병합 사용 태그 :
<?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이 역할을, 우리는 그런 걸 볼 수 있습니다 :
(그것은, 인 IntelliJ의 IDEA, 그냥 같은 안드로이드 스튜디오입니다 이클립스에 대해 나도 몰라)
미리보기는 레이아웃을 많이 개발하는 속도를 높이며, 일부 레이아웃의 경우에도 큰 도움이됩니다. 미리보기에서 특정 레이아웃에서 merge
태그를 어떻게 해석해야 하는지를 지정하는 방법이 있습니까?
이 지원을 추가하고 싶습니다. –
나중에 툴 속성으로 해결할 수 있습니다. https://code.google.com/p/android/issues/detail?id = 61652 – Jonas