开发者

Android Layout: Merge how to position an include

I have a merge layout that has a few includes in it . I need to be able to position relatively. The top a开发者_如何学Pythonnd bottom ones are easy because you can use android:layout_gravity="bottom" OR android:layout_gravity="top". Now, is there a way to positing a third include relative to the one at the top (right below it)? . I read you can wrap the includes in a RelativeLayout but doesn't that defeat the purpose of using Merge?

    <merge
   xmlns:android="http://schemas.android.com/apk/res/android">


    <com.testmerge.TitleBar
       id="@+id/titlebar"
       android:layout_width="fill_parent"
       android:layout_height="35dip"
       android:layout_gravity="top"
               android:paddingTop="0dip"
       android:background="@drawable/title_bar"
    />

   <com.testmerge.StatusBar
       android:layout_width="fill_parent"
       android:layout_height="35dip"
       android:paddingTop="0dip"
       android:background="@drawable/title_bar"
   />

   <com.testmerge.OkCancelBar
       android:layout_width="fill_parent"
       android:layout_height="60dip"
       android:layout_gravity="bottom"
               android:paddingTop="0dip"
       android:background="@drawable/header_bkgrnd"
   />

   <!--"#AA000000"-->
</merge>


Well, the merge tag was created to defeat the extra complexity that is being created in the view hierarchy for the sake of simplicity in your layout definition XML.

If you refer to the merge explanation page, you will see how the TextView that is added before the frame layout occupies some space. The rest of the space is automatically filled with a FrameLayout, so that the available free space has concrete bounds at any point of time. If we add another Layout, that takes up that space, then the automatically created FrameLayout becomes useless. The tag solves that by adding children to the automatically created FrameLayout as if that layout has been declared in our XML. And that is the purpose of the <merge /> tag.

In your case, you probably need a RelativeLayout, as your application obviously requires more complexity. I believe the <merge /> tag is not the solution for you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜