2016-04-09 45 views
1

下面顯示了兩個圖像(加號和​​乘號)。點擊'加號'圖像時,'乘號'圖像開始從'加號'圖像,並在屏幕的末尾顯示附加的最後一張圖片。我的問題是'多'圖像是在附加的第二個圖像中顯示'加'圖像前動畫。我想要在'加'圖像不在前面。如何在Android中設置其他圖像視圖後面的動畫圖像視圖

我對圖像的佈局XML:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 


<LinearLayout 
    android:id="@+id/parent" 
    android:layout_width="match_parent" 
    android:layout_height="40dp" 
    android:layout_marginTop="100dp" 
    android:clipChildren="false" 
    android:clipToPadding="false"> 

    <ImageView 
     android:id="@+id/plus" 
     android:layout_width="80dp" 
     android:layout_height="wrap_content" 
     android:clickable="true" 
     android:clipChildren="true" 
     android:clipToPadding="true" 
     android:scaleType="centerInside" 
     android:src="@drawable/plus" /> 


    <ImageView 
     android:id="@+id/multiply" 
     android:layout_width="80dp" 
     android:layout_height="wrap_content" 
     android:adjustViewBounds="true" 
     android:clickable="true" 
     android:scaleType="centerInside" /> 

</LinearLayout> 
</LinearLayout> 

enter image description here

enter image description here

enter image description here

回答

1

只是使用Relative layout和改變一點點......像這樣

<RelativeLayout 
    android:id="@+id/parent" 
    android:layout_width="match_parent" 
    android:layout_height="40dp" 
    android:layout_marginTop="100dp" 
    android:clipChildren="false" 
    android:clipToPadding="false"> 

    <ImageView 
     android:id="@+id/multiply" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:adjustViewBounds="true" 
     android:clickable="true" 
     android:src="@android:drawable/btn_star_big_on" 
     android:scaleType="centerInside" /> 

    <ImageView 
     android:id="@+id/plus" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:clickable="true" 
     android:clipChildren="true" 
     android:clipToPadding="true" 
     android:scaleType="centerInside" 
     android:src="@android:drawable/btn_star_big_off" /> 

</RelativeLayout> 

enter image description here

+0

謝謝你這麼多,使用相對佈局代替線性佈局解決了我的問題。 – nihasmata

1
  1. 更改XML佈局序列:

    • 對於RelativeLayout的,你在XML寫的第一個視圖將首先繪製。
    • 因此,您需要先編寫imageview,然後再加上imageview。
  2. 如果要動態更改z順序,可以使用view.bringToFront()API。

+0

非常感謝,使用相對佈局而不是線性佈局解決了我的問題。 – nihasmata

相關問題