LinearLayoutに基づいて複合コンポーネントを開発しているとしましょう。我々はsomelayout.xml
のルートとしてLinearLayout
を使いますならば、我々は、余分なビューのレベルを持っていますIntellij IDEA/Androidスタジオのマージルートタグ付きプレビューレイアウト
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>
しかし中
(それはのIntelliJ IDEAは、私にはわからないのEclipseについて、ちょうど同じであるAndroidのメーカー、です)
0:IDEの[プレビュー]タブには、常にでframeLayoutとして働き、そして私たちはそのような何かを見ることができますマージプレビューではレイアウトの開発がスピードアップしていますが、レイアウトによってはこのような大きな助けを失います。プレビューが特定のレイアウトでmerge
タグを解釈する方法を指定する方法がありますか?
このサポートも追加されています。 –
これは、ツール属性によって将来的に解決されるかもしれません。 https://code.google.com/p/android/issues/detail?id = 61652 – Jonas