HI全部,Android佈局障礙
我m在android中的一個應用程序工作。在主屏幕上,我有6個按鈕。
這樣。在按鈕上有一個顯示當前日期的透明視圖。
問題:
- 我不能設計爲相同的佈局。
- 我沒有得到如何在同一窗口上重疊兩個視圖。
- 如果我做六個按鈕,之後如果我採取另一種佈局背景佈局是隱藏的,它根本沒有顯示。
我知道的這件事是我們需要一個視圖上的兩個視圖我可以顯示6個按鈕和在anthoer視圖上我可以顯示日期。但是如何?
在此先感謝
HI全部,Android佈局障礙
我m在android中的一個應用程序工作。在主屏幕上,我有6個按鈕。
這樣。在按鈕上有一個顯示當前日期的透明視圖。
問題:
我知道的這件事是我們需要一個視圖上的兩個視圖我可以顯示6個按鈕和在anthoer視圖上我可以顯示日期。但是如何?
在此先感謝
檢查這個佈局就必須幫助你解決你的問題
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:text="Hello"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"></Button>
<Button
android:text="Hello"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_alignParentLeft="true"></Button>
<Button
android:text="Hello"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"></Button>
<Button
android:text="Hello"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"></Button>
<Button
android:text="Hello"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_alignParentRight="true"></Button>
<Button
android:text="Hello"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"></Button>
</RelativeLayout>
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/icon"/>
</FrameLayout>
使圖像透明看到this
據我瞭解,你需要爲疊加在另一個上面一個看法?
爲此,您需要合併視圖並使頂部視圖透明。看看這篇文章... Layout Tricks: Merging Layouts
這裏的關鍵是FrameLayout
。垂直堆疊在一起的FrameLayout
的孩子。
喜歡的東西
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- The relative layout contains all of your buttons -->
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:id="@+id/button1"
android:text="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/button2"
android:text="2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/button1"
/>
<Button
android:id="@+id/button3"
android:text="3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/button1"
/>
<Button
android:id="@+id/button4"
android:text="4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/button2"
android:layout_toRightOf="@id/button3"
/>
<Button
android:id="@+id/button5"
android:text="5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/button3"
/>
<Button
android:id="@+id/button6"
android:text="6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/button4"
android:layout_toRightOf="@id/button5"
/>
</RelativeLayout>
<!-- Your overlay -->
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:id="@+id/overlayText"
android:text="Overlay"
/>
</RelativeLayout>
</FrameLayout>
您可能需要使用一些嵌套LinearLayout
S(雖然儘量避免吧),如果你不能完全得到你想要的造型與單一RelativeLayout
對準你的按鈕。
謝謝你約瑟夫解決我的問題。 – 2011-03-22 11:51:19
謝謝Sunil你也解決了我的問題。 – 2011-03-22 12:00:40