mardi 5 mai 2015

Use of merge tag

sorry, maybe this question is stupid, but I want to make it clearer, because example on Android Developer a bit unclear for me.

I understand how it basically works, but still not sure about some things.

  1. Merge and include tags used to decrease amount of views/viewgroups in view hierarchy, so we can have reusable part of xml layout. Here is an example of Merge Android Developers Blog . Framelayout is used in this example,we can another FrameLayout with id/content in the view hierarchy, but there is no example where this frame layout is used. Does it mean that FrameLayout is container and looks something like that in xml
 <FrameLayout xmlns:android="http://ift.tt/nIICcg"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
    android:id=”@+id/content>
    <include layout="@layout/our_merge_layout"/>
    </FrameLayout>

Or FrameLayout with content id is created automatically when we are using merge and include tag.

  1. But what to do if we have relative positioning, for instance, should we keep RelativeLayout as ViewGroup wrapper or we can just save all attributes of nested views ( android:layout_below="@id/name",android:layout_alignParentLeft="true") BUT in this case we have to include this part ONLY inside relative layout(in our case ) to make it works ? Am I right ?

  2. What is better to use merge tag or Custom View ?

I would be grateful for any help. Please help to understand this. Thank you in advance.

Aucun commentaire:

Enregistrer un commentaire