2014-02-17 96 views
1

我將如何在Android中構建此佈局?如何在Android中構建此佈局?

enter image description here

我希望所有的三個元素是一個FrameLayout裏那麼在運行時,我可以插入代碼 片段我有圓角和虛線角落的代碼。我只是在將幀佈局放置在彼此之上時遇到問題。或者,也許這3個元素應該是相對佈局?

+1

我想他們應該是相對佈局。幀佈局並不是真的意味着被對齊等。 – AndyFaizan

回答

2

所有這三個元素應該是框架佈局,但根元素應該是相對佈局。另請注意,在相對佈局中,元素被定位爲從最低層到最高層的層。 (由上到XML文件的底部)的第一個元素 - 是最低的,其次是在第一次的頂部,等

您的佈局應該是這樣的:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <FrameLayout 
     android:id="@+id/container_square_with_rounded_corners" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true"/> 

    <FrameLayout 
     android:id="@+id/container_circle" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentBottom="true"/> 

    <FrameLayout 
     android:id="@+id/container_square" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentBottom="true"/> 

</RelativeLayout> 
+0

不錯!謝啦兄弟 – sirvon