0

我经常使用具有相同属性的相同 LinearLayout。例如:

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        ... other views & viewgroups here ....
</LinearLayout>

我想定义一个 XML 布局组件,我们称之为FullScreenVerticalLinearLayout,我会像这样使用它:

<FullScreenVerticalLinearLayout>
        ... other views & viewgroups here ....
</FullScreenVerticalLinearLayout>

<include><merge>标签似乎非常适合视图的可重用性和聚合,但不适用于视图组。关于如何做到这一点的任何线索?谢谢。

4

1 回答 1

2

通过样式。http://developer.android.com/guide/topics/ui/themes.html 例如添加到styles.xml:

<style name="LayoutStyle">
    <item name="android:layout_width">match_parent</item>
    <item name="android:layout_height">match_parent</item>
</style>

并设置这种风格:

<LinearLayout
    style="@style/LayoutStyle">
    ... other views & viewgroups here ....
</LinearLayout>
于 2014-12-25T18:15:51.977 回答