0

I often use the same LinearLayout with the same properties. For instance:

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

I would like to define an XML layout component, let's call it FullScreenVerticalLinearLayout, which i would use like this:

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

<include> or <merge> tags seem to be perfect for view's reusability and aggregation, but not for viewgroup. Any clue on how to do this? Thanks.

Flashbump
  • 221
  • 3
  • 9

1 Answers1

2

Via styles. http://developer.android.com/guide/topics/ui/themes.html For example add this to styles.xml:

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

And set this style:

<LinearLayout
    style="@style/LayoutStyle">
    ... other views & viewgroups here ....
</LinearLayout>
Holoceo
  • 168
  • 2
  • 7
  • Although we are not defining a new tag, but grouping properties, this adds the readability i was looking for. – Flashbump Dec 25 '14 at 18:20