2013-03-26 18 views
0

我試圖將兩個imageviews頂部放置一個圖像部分 -Android的 - 對其他

<ImageView 
    android:id="@+id/ivLogo" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:focusable="true" 
    android:layout_marginTop="20dp" 
    /> 

<ImageView 
    android:id="@+id/ivAction" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="110dp" 
    android:layout_centerHorizontal="true" 
    android:focusable="true" 
    /> 


有圖像之間存在一些重疊。
動作圖像與徽標重疊。
這是預期的行爲,因爲它們在屏幕上都有一些共同的空間。

動作圖像的頂部出現在徽標的頂部,而我希望徽標的底部出現在動作圖像的頂部。
發生了什麼 - 行動是在上面

- enter image description here

需要什麼 - 行動應該去後臺

enter image description here

我會非常感謝幫幫我。

回答

1

只需更改XML中2個ImageView的順序即可。系統以相同的順序繪製它們,所以無論你先放置什麼,都會在底部。

+0

真的很有用....標記爲答案... – Anukool 2013-03-26 08:34:04

1

使用RelativeLayout並更改ImageView的順序。事情會爲你工作。

+0

+1。感謝你的回答... – Anukool 2013-03-26 08:34:35

0

試試這個。這會將您的頂部圖像置於背景圖像的中心

<RelativeLayout 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 

<ImageView 
    android:id="@+id/ivLogo" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:focusable="true" 
    android:layout_marginTop="20dp" 
    /> 

<ImageView 
    android:id="@+id/ivAction" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="110dp" 
    android:layout_centerInParent="true" 
    android:focusable="true" 
    /> 
</RelativeLayout>