当前位置:   article > 正文

android merge的作用,include及merge在androidmanifest.xml中的作用

android androidmanifest.xml merge

Although Android offers a variety of widgets to provide small and re-usable interactive elements, you might also need to re-use larger components that require a special layout. To efficiently re-use complete layouts, you can use the and tags to embed another layout inside the current layout.

Reusing layouts is particularly powerful as it allows you create reusable complex layouts. For example, a yes/no button panel, or custom progress bar with description text. It also means that any elements of your application that are common across multiple layouts can be extracted, managed separately, then included in each layout. So while you can create individual UI components by writing a custom

Create a Re-usable Layout

If you already know the layout that you want to re-use, create a new XML file and define the layout. For example, here's a layout from the G-Kenya codelab that defines a title bar to be included in each activity (titlebar.xml):

The root

Use the Tag

Inside the layout to which you want to add the re-usable component, add the tag. For example, here's a layout from the G-Kenya codelab that includes the title bar from above:

Here's the layout file:

...

You can also override all the layout parameters (any android:layout_* attributes) of the included layout's root view by specifying them in the tag. For example:

However, if you want to override layout attributes using the tag, you must override both android:layout_height and android:layout_width in order for other layout attributes to take effect.

Use the Tag

The tag helps eliminate redundant view groups in your view hierarchy when including one layout within another. For example, if your main layout is a vertical

To avoid including such a redundant view group, you can instead use the element as the root view for the re-usable layout. For example:

Now, when you include this layout in another layout (using the tag), the system ignores the element and places the two buttons directly in the layout, in place of the tag.

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/824309
推荐阅读
相关标签
  

闽ICP备14008679号