Lines Matching refs:code
4 <p>The articles showed you how to use the <code><include /></code> tag in XML layouts, to
5 reuse and share your layout code. This article explains the <code><merge /></code> tag and how
6 it complements the <code><include /></code> tag.</p>
8 <p>The <code><merge /></code> tag was created for the purpose of
49 <code>FrameLayout</code> defined in our XML file (highlighted in blue below) is
50 the sole child of another <code>FrameLayout</code>:</p>
54 <p>Since our <code>FrameLayout</code> has the same dimension as its parent, by
55 the virtue of using the <code>fill_parent</code> constraints, and does not
58 we get rid of this <code>FrameLayout</code>? After all, XML documents require a
61 <p>That's where the <code><merge /></code> tag comes in handy. When the
63 the <code><merge /></code> children to the <code><merge /></code>
65 <code>FrameLayout</code> with <code><merge /></code>:</p>
91 <p>With this new version, both the <code>TextView</code> and the
92 <code>ImageView</code> will be added directly to the top-level
93 <code>FrameLayout</code>. The result will be visually the same but the view
98 <p>Obviously, using <code><merge /></code> works in this case because the
99 parent of an activity's content view is always a <code>FrameLayout</code>. You
100 could not apply this trick if your layout was using a <code>LinearLayout</code>
101 as its root tag for instance. The <code><merge /></code> can be useful in
103 <code><include /></code> tag. You can also use <code><merge
104 /></code> when you create a custom composite view. Let's see how we can use
105 this tag to create a new view called <code>OkCancelBar</code> which simply shows
108 source code of this example</a>. Here is the XML used to display this custom
141 <p>The source code of <code>OkCancelBar</code> is very simple because the two
143 <code>LayoutInflate</code>. As you can see in the following snippet, the XML
144 layout <code>R.layout.okcancelbar</code> is inflated with the
145 <code>OkCancelBar</code> as the parent:</p>
171 use the <code><merge /></code> tag to add the two buttons directly to the
172 <code>OkCancelBar</code>. Each button is included from the same external XML
190 <p>The <code><merge /></code> tag is extremely useful and can do wonders
191 in your code. However, it suffers from a couple of limitations:</p>
194 <li><code><merge /></code> can only be used as the root tag of an XML layout</li>
195 <li>When inflating a layout starting with a <code><merge /></code>, you <strong>must</strong>
196 specify a parent <code>ViewGroup</code> and you must set <code>attachToRoot</code> to
197 <code>true</code> (see the documentation for