2012-01-11 77 views
2

我是Android中的新人,所以請爲愚蠢抱歉。 那麼我的問題是在多個層次 -Android中的圖層應用程序

我想結合兩個透明ImageViews一個在另一個之上。這與photoshops圖層類似,android中的示例圖層活動是什麼?

回答

0

已經回答Overlapping Views in Android?這應該是你需要的一切,使用RelativeLayout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/layout" 
> 
<ImageView android:id="@+id/imageview1" 
    android:background="#00000000" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:src="@drawable/image1" 
    /> 

<ImageView android:id="@+id/imageview2" 
    android:background="#00000000" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:src="@drawable/image2" 
    /> 

</RelativeLayout> 

將是一個示例代碼給你。

+0

謝謝..我試過這個代碼,但仍然屏幕是空白的。我應該在代碼中添加其他任何內容,否則只有這個xml文件會做? – 2012-01-12 11:36:15

+0

您需要3個其他文件:分別爲image1,image2,以及引用RelativeLayout的.java文件。我也會檢查清單,但這是另一個問題的答案。希望就夠了。 – TryTryAgain 2012-01-12 16:57:42

+0

我在drawable中添加了三張圖片。那麼它也不起作用。幫幫我。現在我的應用程序在main.xml中有3個圖像和這個xml文件。 – 2012-01-13 09:06:04

1

您可以爲此使用RelativeLayout。

屬性android:layout_centerInParent如果爲true,則在其父項中水平和垂直居中對齊子項。 [布爾]

同樣有像, 機器人性能:layout_alignParentLeft,

機器人:layout_alignParentRight,

機器人:layout_alignParentTop,

機器人:layout_alignParentBottom。

試試這些。

0

可以使用層列表,用於全面調查,請參閱​​

0

那麼它很可能在android中完成,但事實上你將要做的是這個。您可以爲佈局中的圖像提供相同的位置,現在這兩個圖像將會重疊並根據您的條件或情況進行編程顯示和隱藏。以同樣的方式,你可以給多個圖像重疊在一起。希望這會幫助你理解:)

+0

謝謝我現在嘗試它能夠看到兩個圖像。一個在另一個之上。我想將動作事件添加到背景中的圖像。我怎樣才能做到這一點 ?你可以幫我嗎? – 2012-02-02 08:47:47